feat: detect duplicate measurement dates, ask to overwrite

This commit is contained in:
Eddy de Vink 2026-06-28 00:39:56 +02:00
commit 1f43918e84
2 changed files with 36 additions and 2 deletions

View file

@ -47,6 +47,15 @@ export async function getLatestMeasurement(): Promise<Measurement | null> {
return rows.length > 0 ? (rows[0] as Measurement) : null
}
export async function getMeasurementByDate(date: string): Promise<Measurement | null> {
const day = date.slice(0, 10)
const rows = await db!.getAllAsync<any>(
"SELECT * FROM measurements WHERE measuredAt LIKE ? LIMIT 1",
[`${day}%`]
)
return rows.length > 0 ? (rows[0] as Measurement) : null
}
export async function updateMeasurement(id: string, syncStatus: SyncStatus): Promise<void> {
await db!.runAsync(
'UPDATE measurements SET syncStatus = ?, updatedAt = ? WHERE id = ?',