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:
@@ -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())
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user