Skip to content

Commit

Permalink
Update charging-stats.json (#642)
Browse files Browse the repository at this point in the history
* Update charging-stats.json

Updated to address #528

Added case statement to adjust to show kWh at non decimal level and MWh at the 3 decimal point level. Cannot address directly within grafana so used case statement. Removed grafana sorting so can be sorted properly in SQL since not a direct # now for grafana to sort.

* Update charging-stats.json

Fixed mWh to MWh

Fixes #528
  • Loading branch information
Dulanic authored Apr 25, 2020
1 parent 2735dc9 commit d364783
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions grafana/dashboards/charging-stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@
"scroll": true,
"showHeader": true,
"sort": {
"col": 1,
"desc": true
"col": null,
"desc": false
},
"styles": [
{
Expand Down Expand Up @@ -1198,7 +1198,7 @@
"mappingType": 1,
"pattern": "charge_energy_added",
"thresholds": [],
"type": "number",
"type": "string",
"unit": "kwatth"
}
],
Expand All @@ -1208,7 +1208,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tsum(charge_energy_added) as charge_energy_added\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\nGROUP BY\n\t1\nORDER BY\n\tcharge_energy_added DESC\nLIMIT 15;",
"rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) BETWEEN 0 AND 999.999 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) BETWEEN 1000 AND 999999.999 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' gWh' \n END as charge_energy_added\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 15;",
"refId": "A",
"select": [
[
Expand Down

0 comments on commit d364783

Please sign in to comment.