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.
This commit is contained in:
Ruben Rosario
2026-06-21 16:15:16 +01:00
parent 98409ff88b
commit 27b42d7836
+4 -1
View File
@@ -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())
});