Skip to content

Commit

Permalink
Allow editing suspect tests without overwriting start date
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Oct 27, 2024
1 parent 7d393df commit 1898067
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,22 @@ export const actions: {[k: string]: QueryHandler} = {
} catch (e: any) {
throw new ActionError("Failed to update Smogon suspect test record: " + e.message);
}
await tables.suspects.replace({
formatid: id,
start_date: start,
elo: reqs.elo || null,
gxe: reqs.gxe || null,
coil: reqs.coil || null,
});
const existing = await tables.suspects.get(id);
if (existing) {
await tables.suspects.update(id, {
elo: reqs.elo || null,
gxe: reqs.gxe || null,
coil: reqs.coil || null,
});
} else {
await tables.suspects.insert({
formatid: id,
start_date: start,
elo: reqs.elo || null,
gxe: reqs.gxe || null,
coil: reqs.coil || null,
});
}
return {success: true};
},
async 'suspects/end'(params) {
Expand Down

0 comments on commit 1898067

Please sign in to comment.