Skip to content

Commit

Permalink
fix: delete duplicated run
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed May 30, 2024
1 parent 749cace commit faff30c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
result
demo*
demo*
kview
19 changes: 15 additions & 4 deletions src/server/kv/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>([
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)
Expand All @@ -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,
Expand Down

0 comments on commit faff30c

Please sign in to comment.