diff --git a/grafana/electoral_district_dashboard.json b/grafana/electoral_district_dashboard.json new file mode 100644 index 0000000..6d41321 --- /dev/null +++ b/grafana/electoral_district_dashboard.json @@ -0,0 +1,940 @@ +{ + "__inputs": [ + { + "name": "DS_MYSQL", + "label": "MySQL", + "description": "", + "type": "datasource", + "pluginId": "mysql", + "pluginName": "MySQL" + } + ], + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "7.0.5" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "datasource", + "id": "mysql", + "name": "MySQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "text", + "name": "Text", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1596462290218, + "links": [], + "panels": [ + { + "content": "\n
${electoral_district_name}
", + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": "center", + "displayMode": "color-text" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 9, + "x": 0, + "y": 0 + }, + "id": 12, + "mode": "html", + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "\n \n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Polling Division", + "type": "text" + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 7, + "x": 9, + "y": 0 + }, + "id": 22, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + } + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT Count(*) as \"Casted Votes\"\nFROM VoteRecords\nWHERE $__timeFilter(Timestamp) and DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\";\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Casted Votes", + "type": "stat" + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 23, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + } + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [ + { + "params": [ + "$__interval", + "none" + ], + "type": "time" + } + ], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT count(ElectorID) AS \"Registered Voters\"\nFROM ElectorRegistry\nWHERE DistrictID = ${electoral_district_id};\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "ElectorID" + ], + "type": "column" + }, + { + "params": [ + "count" + ], + "type": "aggregate" + }, + { + "params": [ + "Registered Voters" + ], + "type": "alias" + } + ] + ], + "table": "voter_registry", + "timeColumn": "none", + "where": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Registered Voters", + "type": "stat" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "description": "", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 2 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "6.6.2", + "pointradius": 2, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [ + { + "params": [ + "$__interval", + "none" + ], + "type": "time" + } + ], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroupAlias(Timestamp,$__interval),\n count(ID) AS \"Vote Count\"\nFROM VoteRecords\nWHERE\n $__timeFilter(Timestamp) and DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\"\nGROUP BY 1\nORDER BY $__timeGroup(Timestamp,$__interval)", + "refId": "A", + "select": [ + [ + { + "params": [ + "ElectorID" + ], + "type": "column" + }, + { + "params": [ + "count" + ], + "type": "aggregate" + }, + { + "params": [ + "Vote Count" + ], + "type": "alias" + } + ] + ], + "table": "vote_records", + "timeColumn": "Timestamp", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Voter Distribution Over Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:573", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:574", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 2 + }, + "id": 7, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": true + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "hide": true, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT COUNT(*) as \"Failed Attempts\"\nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and PollingStationID = $polling_station and Status = \"failed\";", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "table": "voter_registry", + "timeColumn": "time", + "where": [] + }, + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT (COUNT(*)/${casted_votes}) * 100 as \"Male Voters (%)\"\nFROM ElectorRegistry\nWHERE Sex = 'MALE' and ID in (SELECT ID FROM VoteRecords WHERE DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\");", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "table", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT (COUNT(*)/${casted_votes}) * 100 as \"Female Voters (%)\"\nFROM ElectorRegistry\nWHERE Sex = \"FEMALE\" and ID in (SELECT ID FROM VoteRecords WHERE DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\");", + "refId": "C", + "select": [ + [ + { + "params": [ + "ID" + ], + "type": "column" + } + ] + ], + "table": "vote_records", + "timeColumn": "Timestamp", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Gender Statistics", + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": null + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 28, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "7.0.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:109" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and \n\t v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"MALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY Age ASC;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Male Voter Distribution Over Age", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "transformations": [], + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "series", + "name": null, + "show": true, + "values": [ + "total" + ] + }, + "yaxes": [ + { + "$$hashKey": "object:73", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:74", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": null + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 29, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "7.0.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:109" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and \n\t v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"FEMALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY Age ASC;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Female Voter Distribution Over Age", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "transformations": [], + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "series", + "name": null, + "show": true, + "values": [ + "total" + ] + }, + "yaxes": [ + { + "$$hashKey": "object:73", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:74", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 25, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT DISTINCT(Name_EN) FROM ElectoralDistricts;", + "hide": 0, + "includeAll": false, + "label": "District", + "multi": false, + "name": "electoral_district_name", + "options": [], + "query": "SELECT DISTINCT(Name_EN) FROM ElectoralDistricts;", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT ID FROM ElectoralDistricts WHERE Name_EN = N${electoral_district_name:singlequote} ;", + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "electoral_district_id", + "options": [], + "query": "SELECT ID FROM ElectoralDistricts WHERE Name_EN = N${electoral_district_name:singlequote} ;", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT Count(*) \nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\" and $__timeFilter(Timestamp);\n\n", + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "casted_votes", + "options": [], + "query": "SELECT Count(*) \nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and VotingStatus = \"VOTED\" and $__timeFilter(Timestamp);\n\n", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now/d", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Electoral District Dashboard - E Poll Book", + "uid": "-8CSgjVGz", + "version": 4 +} \ No newline at end of file diff --git a/grafana/polling_division_dashboard.json b/grafana/polling_division_dashboard.json new file mode 100644 index 0000000..a5c232e --- /dev/null +++ b/grafana/polling_division_dashboard.json @@ -0,0 +1,984 @@ +{ + "__inputs": [ + { + "name": "DS_MYSQL", + "label": "MySQL", + "description": "", + "type": "datasource", + "pluginId": "mysql", + "pluginName": "MySQL" + } + ], + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "7.0.5" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "datasource", + "id": "mysql", + "name": "MySQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "text", + "name": "Text", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1596462013688, + "links": [], + "panels": [ + { + "content": "\n
${electoral_district_name} / ${polling_division_name}
", + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": "center", + "displayMode": "color-text" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 9, + "x": 0, + "y": 0 + }, + "id": 12, + "mode": "html", + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "\n \n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Polling Division", + "type": "text" + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 7, + "x": 9, + "y": 0 + }, + "id": 22, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + } + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT Count(*) as \"Casted Votes\"\nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\" and $__timeFilter(Timestamp);\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Casted Votes", + "type": "stat" + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 23, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + } + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [ + { + "params": [ + "$__interval", + "none" + ], + "type": "time" + } + ], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT count(ElectorID) AS \"Registered Voters\"\nFROM ElectorRegistry\nWHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote};\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "ElectorID" + ], + "type": "column" + }, + { + "params": [ + "count" + ], + "type": "aggregate" + }, + { + "params": [ + "Registered Voters" + ], + "type": "alias" + } + ] + ], + "table": "voter_registry", + "timeColumn": "none", + "where": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Registered Voters", + "type": "stat" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "description": "", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 2 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "6.6.2", + "pointradius": 2, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [ + { + "params": [ + "$__interval", + "none" + ], + "type": "time" + } + ], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroupAlias(Timestamp,$__interval),\n count(ID) AS \"Vote Count\"\nFROM VoteRecords\nWHERE\n $__timeFilter(Timestamp) and DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\"\nGROUP BY 1\nORDER BY $__timeGroup(Timestamp,$__interval)", + "refId": "A", + "select": [ + [ + { + "params": [ + "ElectorID" + ], + "type": "column" + }, + { + "params": [ + "count" + ], + "type": "aggregate" + }, + { + "params": [ + "Vote Count" + ], + "type": "alias" + } + ] + ], + "table": "vote_records", + "timeColumn": "Timestamp", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Voter Distribution Over Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:573", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:574", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 2 + }, + "id": 7, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": true + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "format": "table", + "group": [], + "hide": true, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT COUNT(*) as \"Failed Attempts\"\nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and PollingStationID = $polling_station and Status = \"failed\";", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "table": "voter_registry", + "timeColumn": "time", + "where": [] + }, + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT (COUNT(*)/${casted_votes}) * 100 as \"Male Voters (%)\"\nFROM ElectorRegistry\nWHERE Sex = 'MALE' and ID in (SELECT ID FROM VoteRecords WHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\");", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "table", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT (COUNT(*)/${casted_votes}) * 100 as \"Female Voters (%)\"\nFROM ElectorRegistry\nWHERE Sex = \"FEMALE\" and ID in (SELECT ID FROM VoteRecords WHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\");", + "refId": "C", + "select": [ + [ + { + "params": [ + "ID" + ], + "type": "column" + } + ] + ], + "table": "vote_records", + "timeColumn": "Timestamp", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Gender Statistics", + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": null + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 28, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "7.0.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:109" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"MALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY Age ASC;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Male Voter Distribution Over Age", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "transformations": [], + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "series", + "name": null, + "show": true, + "values": [ + "total" + ] + }, + "yaxes": [ + { + "$$hashKey": "object:73", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:74", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_MYSQL}", + "fieldConfig": { + "defaults": { + "custom": { + "align": null + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 29, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "7.0.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:109" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"FEMALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY Age ASC;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Female Voter Distribution Over Age", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "transformations": [], + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "series", + "name": null, + "show": true, + "values": [ + "total" + ] + }, + "yaxes": [ + { + "$$hashKey": "object:73", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:74", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 25, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT DISTINCT(Name_EN) FROM ElectoralDistricts;", + "hide": 0, + "includeAll": false, + "label": "District", + "multi": false, + "name": "electoral_district_name", + "options": [], + "query": "SELECT DISTINCT(Name_EN) FROM ElectoralDistricts;", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT ID FROM ElectoralDistricts WHERE Name_EN = N${electoral_district_name:singlequote} ;", + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "electoral_district_id", + "options": [], + "query": "SELECT ID FROM ElectoralDistricts WHERE Name_EN = N${electoral_district_name:singlequote} ;", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT DISTINCT(Name_EN) \nFROM PollingDivisions \nWHERE DistrictID = $electoral_district_id;", + "hide": 0, + "includeAll": false, + "label": "Polling Division", + "multi": false, + "name": "polling_division_name", + "options": [], + "query": "SELECT DISTINCT(Name_EN) \nFROM PollingDivisions \nWHERE DistrictID = $electoral_district_id;", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT ID\nFROM PollingDivisions\nWHERE Name_EN = N${polling_division_name:singlequote};", + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "polling_division_id", + "options": [], + "query": "SELECT ID\nFROM PollingDivisions\nWHERE Name_EN = N${polling_division_name:singlequote};", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_MYSQL}", + "definition": "SELECT Count(*) \nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\" and $__timeFilter(Timestamp);\n\n", + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "casted_votes", + "options": [], + "query": "SELECT Count(*) \nFROM VoteRecords\nWHERE DistrictID = ${electoral_district_id} and PollingDivisionID = ${polling_division_id:singlequote} and VotingStatus = \"VOTED\" and $__timeFilter(Timestamp);\n\n", + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now/d", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Polling Division Dashboard - E Poll Book", + "uid": "DZ6bB9VGk", + "version": 6 +} \ No newline at end of file diff --git a/grafana/polling_station_dashboard.json b/grafana/polling_station_dashboard.json index 48fd48b..4e620c4 100644 --- a/grafana/polling_station_dashboard.json +++ b/grafana/polling_station_dashboard.json @@ -64,7 +64,7 @@ "gnetId": null, "graphTooltip": 0, "id": null, - "iteration": 1596452272469, + "iteration": 1596457080601, "links": [], "panels": [ { @@ -632,7 +632,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.PollingStationID = $polling_station and v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"MALE\" and $__timeFilter(Timestamp)) as t\n\ngroup by `range`\nORDER BY `range` ASC;", + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.PollingStationID = $polling_station and v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"MALE\" and $__timeFilter(Timestamp)) as t\n\ngroup by `range`\nORDER BY Age ASC;", "refId": "A", "select": [ [ @@ -772,7 +772,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.PollingStationID = $polling_station and v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"FEMALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY `range` ASC;", + "rawSql": "SELECT concat(10*floor(Age/10), '-', 10*floor(Age/10) + 10) as \"range\", count(*) as value, current_timestamp AS time\nFROM (\n SELECT v.ID,Sex,Age\n FROM VoteRecords as v\n INNER JOIN ElectorRegistry ON v.ID = ElectorRegistry.ID\n\t WHERE v.DistrictID = ${electoral_district_id} and v.PollingDivisionID = ${polling_division_id:singlequote} and \n\t v.PollingStationID = $polling_station and v.VotingStatus = \"VOTED\" and v.Age != -1 and Sex = \"FEMALE\" and $__timeFilter(Timestamp)) as t\ngroup by `range`\nORDER BY Age ASC;", "refId": "A", "select": [ [ @@ -1002,5 +1002,5 @@ "timezone": "", "title": "Polling Station Dashboard - E Poll Book", "uid": "y_Ua1V9Wz", - "version": 49 + "version": 50 } \ No newline at end of file