🌳
pt0/gamesapp/serverF/telgame/saveResultsF.mts
1import { sql } from 'kysely'
4import type { GamesDB } from '../gamesDbF.d.ts'
6type ExistingGame = {
7 id: string
8 isEphemeralGame?: boolean
9}
11export const saveResults = async ({existingGame}: {existingGame: ExistingGame}) => {
12 const {id} = existingGame
13 if (existingGame.isEphemeralGame) return
16 // Mark game as finished (no billing in stripped version)
17 const updateResult = await db.updateTable('dbgames')
18 .set({created_at: sql`now()`, is_finished: true})
19 .where('id', '=', id)
20 .executeTakeFirst()
22 if (Number(updateResult.numUpdatedRows) === 0) {
23 noThrowNotifErr('saveResults: game row not found', {id})
24 }