speedwagon

How fast am I going? How fast was I going a week ago?

git clone https://code.pdelong.com/speedwagon.git

 1package com.pdelong.speedwagon
 2
 3import androidx.room.Dao
 4import androidx.room.Insert
 5import androidx.room.Query
 6import kotlinx.coroutines.flow.Flow
 7
 8@Dao
 9interface LocationReadingDao {
10    @Query("SELECT * FROM readings")
11    suspend fun getAll(): List<LocationReading>
12
13    @Insert
14    suspend fun insert(vararg locations: LocationReading)
15
16    @Query("SELECT AVG(speed) AS avg, MAX(speed) AS max FROM readings WHERE recording_id = :recordingId")
17    suspend fun recordingStats(recordingId: Long): RecordingStats
18
19    @Query("SELECT * FROM readings WHERE recording_id = :recordingId ORDER BY timestamp DESC LIMIT 1")
20    fun latestForRecording(recordingId: Long): Flow<LocationReading?>
21}