hive-c0re: finish chrono-clock migration

This commit is contained in:
damocles 2026-08-01 23:55:00 +02:00 committed by mara
commit 9293c5d580
14 changed files with 82 additions and 78 deletions

View file

@ -7,7 +7,7 @@ use std::path::Path;
use std::sync::Mutex;
use anyhow::{Context, Result, bail};
use hive_sh4re::wire_time::now_unix;
use chrono::Utc;
use hive_sh4re::{Approval, ApprovalKind, ApprovalStatus};
use rusqlite::{Connection, OptionalExtension, params};
@ -95,7 +95,7 @@ impl Approvals {
agent,
kind.as_str(),
commit_ref,
now_unix(),
Utc::now().timestamp(),
description,
submitter,
fetched_sha,
@ -206,7 +206,7 @@ impl Approvals {
if row.status != "pending" {
bail!("approval {id} is {}, not pending", row.status);
}
let resolved_at = now_unix();
let resolved_at = Utc::now().timestamp();
conn.execute(
"UPDATE approvals SET status = 'approved', resolved_at = ?1 WHERE id = ?2",
params![resolved_at, id],
@ -230,7 +230,7 @@ impl Approvals {
let affected = conn.execute(
"UPDATE approvals SET status = 'denied', resolved_at = ?1, note = ?2
WHERE id = ?3 AND status = 'pending'",
params![now_unix(), note, id],
params![Utc::now().timestamp(), note, id],
)?;
if affected == 0 {
bail!("approval {id} not pending");
@ -242,7 +242,7 @@ impl Approvals {
let conn = self.conn.lock().unwrap();
conn.execute(
"UPDATE approvals SET status = 'failed', resolved_at = ?1, note = ?2 WHERE id = ?3",
params![now_unix(), note, id],
params![Utc::now().timestamp(), note, id],
)?;
Ok(())
}
@ -267,7 +267,7 @@ impl Approvals {
if row.status != "pending" {
bail!("approval {id} is {}, not pending", row.status);
}
let resolved_at = now_unix();
let resolved_at = Utc::now().timestamp();
let note = format!("cancelled by {canceller}");
tx.execute(
"UPDATE approvals SET status = 'cancelled', resolved_at = ?1, note = ?2 WHERE id = ?3",
@ -295,7 +295,7 @@ impl Approvals {
let n = conn.execute(
"UPDATE approvals SET status = 'failed', resolved_at = ?1, note = ?2
WHERE agent = ?3 AND status = 'pending'",
params![now_unix(), note, agent],
params![Utc::now().timestamp(), note, agent],
)?;
Ok(n)
}