Show efficiency by speed in Efficiency Dashboard #2661
Starmixcraft
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi There,
I thought it would be nice if we could see the efficiency of the car grouped by the average speed. It uses the same diagram type as Temperature – Efficiency with a few column tweaks.
Therefore, I wrote my own SQL to retrieve the data accordingly. Maybe this is useful to more people than me that why I'm sharing it here.
Iv tried to cover length and speed conversion in the quarry, but I'm not sure if I got everything right (It's only tested with ideal range and km as output). This is more an improvement proposal as an idea, but sadly there is no category for that :(
WITH DATA AS (SELECT car_id, SUM(distance) AS total_distance, SUM(duration_min) AS total_duration, sum(start_ideal_range_km - end_ideal_range_km) AS total_ideal_range, sum(start_rated_range_km - end_rated_range_km) AS total_rated_range, ROUND(convert_km(distance::numeric, 'km') / duration_min * 60 / 5, 0) * 5 AS av_speed_raw FROM drives WHERE duration_min > 0 AND car_id = 1 GROUP BY av_speed_raw, car_id order by av_speed_raw desc) SELECT av_speed_raw / (CASE WHEN '$length_unit' = 'km' THEN 1 WHEN '$length_unit' = 'mi' THEN 1.60934 END) as avg_speed_$length_unit, total_distance / total_[[preferred_range]]_range AS efficiency, total_[[preferred_range]]_range / total_distance * c.efficiency * 1000 AS consumption_$length_unit, convert_km(total_distance::numeric, '$length_unit') AS total_distance_$length_unit FROM DATA JOIN cars c ON DATA.car_id = c.id;
Beta Was this translation helpful? Give feedback.
All reactions