diff --git a/.gitignore b/.gitignore index 7520387..7071fef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ result -demo* \ No newline at end of file +demo* +kview \ No newline at end of file diff --git a/src/server/kv/runs.ts b/src/server/kv/runs.ts index 4706181..24185e9 100644 --- a/src/server/kv/runs.ts +++ b/src/server/kv/runs.ts @@ -12,13 +12,20 @@ export async function save(project: string, data: Run) { const run = await get(data.id); - await kv.delete([ + const { value: runDate } = await kv.get([ FLUENTCI_KV_PREFIX, - "runs_by_date", - project, - dayjs(_.get(run, "date", data.date)).unix(), + "run_date", + data.id, ]); + if (runDate) { + await kv + .atomic() + .delete([FLUENTCI_KV_PREFIX, "runs_by_date", project, runDate]) + .delete([FLUENTCI_KV_PREFIX, "run_date", data.id]) + .commit(); + } + await kv .atomic() .set([FLUENTCI_KV_PREFIX, "runs", project, data.id], data) @@ -33,6 +40,10 @@ export async function save(project: string, data: Run) { ], data ) + .set( + [FLUENTCI_KV_PREFIX, "run_date", data.id], + dayjs(_.get(run, "date", data.date)).unix() + ) .set( [ FLUENTCI_KV_PREFIX,