1import { sql } from 'kysely'2import { getTransactOrDbKys } from '../../../serverF/dbF/kyselyTransactCtxF.mts'3import { noThrowNotifErr } from '../../../serverF/throwErrorF/noThrowNotifErrF.mts'4import type { GamesDB } from '../gamesDbF.d.ts'6type ExistingGame = {7 id: string8 isEphemeralGame?: boolean9}11export const saveResults = async ({existingGame}: {existingGame: ExistingGame}) => {12 const {id} = existingGame13 if (existingGame.isEphemeralGame) return14 const db = getTransactOrDbKys<GamesDB>()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 }25}