From a72acbc42fc1dc9d17f8a2520fbcc4c4566e708b Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sat, 27 Jul 2024 18:18:10 +0100 Subject: [PATCH] Complete set --- src/main.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0a49f38..5b94f0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,6 +91,45 @@ impl Worker { self.update_tags().await?; } + for entry in time_entries { + sqlx::query!( + r#" + INSERT INTO time_entries (id, workspace_id, user_id, project_id, task_id, start, stop, duration, updated_at, description, tag_ids, billable, server_deleted_at, permissions) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) + ON CONFLICT (id) DO UPDATE SET + workspace_id = excluded.workspace_id, + user_id = excluded.user_id, + project_id = excluded.project_id, + task_id = excluded.task_id, + start = excluded.start, + stop = excluded.stop, + duration = excluded.duration, + updated_at = excluded.updated_at, + description = excluded.description, + tag_ids = excluded.tag_ids, + billable = excluded.billable, + server_deleted_at = excluded.server_deleted_at, + permissions = excluded.permissions + "#, + entry.id as i64, + entry.workspace_id as i64, + entry.user_id as i64, + entry.project_id.map(|id| id as i64), + entry.task_id.map(|id| id as i64), + entry.start, + entry.stop, + entry.duration.map(|d| d as i32), + entry.updated_at, + entry.description, + &entry.tag_ids.iter().map(|id| *id as i64).collect::>(), + entry.billable, + entry.server_deleted_at, + entry.permissions, + ) + .execute(&mut self.db) + .await?; + } + Ok(()) }