Sunswift Fastest Lap Speed

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠

Excalidraw Data

Text Elements

Problem: Adding a top speed to each lap on Grafana

To do:

Relevant Query Headings:

Questions to ask:

If databases are separate:

WITH merged_data AS (
SELECT
q.gps_speed,
q.time,
l.lap_time
FROM
queries q
LEFT JOIN
lap_times l
ON
q.time <= l.time
ORDER BY
q.time DESC
)
SELECT
lap_time,
MAX(gps_speed) AS max_gps_speed
FROM
merged_data
GROUP BY
lap_time;

This makes it so that we associate each query entry from queries 'q' to the earlier lap timestamp -> each row in
the 'queries' table, is mapped to a particular lap time
from 'lap_times'

From the combined table, we group the results by lap_time and get the maximum GPS speed from each group

Grafana will let me query two separate databases, but I'm not sure
how I would go about joining both of them together

Query 1:
SELECT
avg(case when measure_name = '/car/speed/gps' then measure_value::double end) as "GPS Speed",
bin(time, parse_duration('$__interval_ms')) as time
FROM
__database.__table
WHERE
measure_name IN ('/car/speed/gps')
AND $__timeFilter
ORDER BY
time DESC

^ This query returns the "gps speed" of the car in the first column, followed by the time corresponding to each recorded gps speed in the second time, I need to figure out:

Query 2:
SELECT
to_milliseconds(lag(time, 1) over (order by time desc) - time) as "Lap Time",
time as "starting time"
FROM __database.__table
ORDER BY
time DESC

^ This query returns the lap time for each lap in the first column in milliseconds(?), followed by the starting time in the second column, with time in descending order (last recorded lap time at the top)

I think that what I need to do, is somehow map lap times in dashboard 1 to GPS Speed times in dashboard 2. So:
* For each entry in the GPS Speed database, check which timeframe/time period it's between then assign it to a certain lap time based on that time period
* E.g. for GPS speed 57.9 km/hr at 15:20:20, it would be assigned to lap time 195584 at 15:17:37 since it's greater than that time, but less than the start of the next lap which is at 15:20:53

UPDATE:

Adjust this to change the interval measured
(higher max data points = lower interval = more accurate readings for fastest GPS speed)

To find the fastest time:

Embedded Files

5e6bb2c42c01d57ec6ecc1d6379cd701efb23c6f: [[Pasted Image 20240612174153_931.png]]
ec9d852de0ff502dd1b1df5b2f319d38e60fbb57: [[Pasted Image 20240624092036_841.png]]