This commit is contained in:
Dominic Ferrando
2026-09-26 18:27:33 -04:00
parent b66980c0fb
commit 930bd61e62
4 changed files with 87 additions and 81 deletions
+4 -3
View File
@@ -24,10 +24,11 @@ export class AssessmentsService {
.executeTakeFirstOrThrow();
}
async get(id: string) {
async get(id: string, accountId?: string) {
return await db.selectFrom("assessments")
.selectAll()
.where("id", "=", id)
.$if(accountId !== undefined, (qb) => qb.where("account_id", "=", accountId!))
.executeTakeFirst();
}
@@ -48,7 +49,7 @@ export class AssessmentsService {
}
async update(id: string, player: Player, activityPerformances: ActivityPerformance[]) {
const result = await db.updateTable("assessments")
return await db.updateTable("assessments")
.where("id", "=", id)
.set({
name: player.name ?? "Anonymous",
@@ -62,8 +63,8 @@ export class AssessmentsService {
perf_run: AssessmentsService.performanceFor(activityPerformances, Activity.Run),
perf_cone_drill: AssessmentsService.performanceFor(activityPerformances, Activity.ConeDrill),
})
.returning("id")
.executeTakeFirst();
return result.numUpdatedRows > 0n;
}
async delete(id: string, accountId: string): Promise<boolean> {