fix(db): use single timestamp in markRefreshed + recordAutomationExecution (P1-23, P3-46)

This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 22:55:33 -04:00
1 parent c93b28925b
commit 9a5cdad86e
2 files changed
+5 -3

No files matched your search

+3 -2
View File
@@ -53,8 +53,9 @@ export function buildAutomationMethods(
recordAutomationExecution(ruleId: string, companyId: string, ruleName: string, trigger: string, action: string, detail: string) {
const id = randomUUID();
getDb().prepare("insert into automation_log (id, company_id, rule_id, rule_name, trigger, action, detail, executed_at) values (?, ?, ?, ?, ?, ?, ?, ?)").run(id, companyId, ruleId, ruleName, trigger, action, detail, nowIso());
getDb().prepare("update automation_rules set execution_count = execution_count + 1, last_executed_at = ? where id = ?").run(nowIso(), ruleId);
const ts = nowIso();
getDb().prepare("insert into automation_log (id, company_id, rule_id, rule_name, trigger, action, detail, executed_at) values (?, ?, ?, ?, ?, ?, ?, ?)").run(id, companyId, ruleId, ruleName, trigger, action, detail, ts);
getDb().prepare("update automation_rules set execution_count = execution_count + 1, last_executed_at = ? where id = ?").run(ts, ruleId);
},
getAutomationLog(companyId: string) {
+2 -1
View File
@@ -166,11 +166,12 @@ export function buildCredentialMethods(
ciphertext: Uint8Array,
expiresAt: string | null,
): void {
const ts = nowIso();
getDb()
.prepare(
"update credentials set backend = ?, ciphertext = ?, expires_at = ?, last_refreshed_at = ?, status = 'active', last_error = null, updated_at = ? where connector_id = ?",
)
.run(backend, ciphertext, expiresAt, nowIso(), nowIso(), connectorId);
.run(backend, ciphertext, expiresAt, ts, ts, connectorId);
}
return { list, get, upsert, remove, setStatus, markRefreshed };