From 27b42d7836ef23852edc45be00c3739805523c16 Mon Sep 17 00:00:00 2001 From: Ruben Rosario Date: Sun, 21 Jun 2026 16:15:16 +0100 Subject: [PATCH] Fix created_at > updated_at for API-synced tasks Use updated_at as fallback for created_at when no existing row, so API tasks have created_at <= updated_at. --- src/infrastructure/db.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/db.rs b/src/infrastructure/db.rs index 6c4ab7c..a33aa55 100644 --- a/src/infrastructure/db.rs +++ b/src/infrastructure/db.rs @@ -140,7 +140,9 @@ impl Db { task.position }; - // Preserve existing created_at if the task already exists + // Preserve existing created_at if the task already exists. + // For new tasks from API, use updated_at as created_at proxy + // (Google Tasks API does not provide a creation timestamp). let created_at = task.created_at.unwrap_or_else(|| { conn.query_row( "SELECT created_at FROM tasks WHERE id = ?1", @@ -149,6 +151,7 @@ impl Db { ) .ok() .and_then(|s| NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S").ok()) + .or_else(|| task.updated_at) .unwrap_or_else(|| chrono::Utc::now().naive_utc()) });