From 61a2bcb60942482fe830315c11fbcdcd75f708ff Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Fri, 17 Jun 2022 00:15:37 -0700 Subject: [PATCH] Don't unnecessarily query contract in onCreateBet (#528) --- functions/src/on-create-bet.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/functions/src/on-create-bet.ts b/functions/src/on-create-bet.ts index af3a6e84..3e615e42 100644 --- a/functions/src/on-create-bet.ts +++ b/functions/src/on-create-bet.ts @@ -1,7 +1,6 @@ import * as functions from 'firebase-functions' import * as admin from 'firebase-admin' -import { getContract } from './utils' import { Bet } from '../../common/bet' const firestore = admin.firestore() @@ -12,16 +11,11 @@ export const onCreateBet = functions.firestore const { contractId } = context.params as { contractId: string } - - const contract = await getContract(contractId) - if (!contract) - throw new Error('Could not find contract corresponding with bet') - const bet = change.data() as Bet const lastBetTime = bet.createdTime await firestore .collection('contracts') - .doc(contract.id) + .doc(contractId) .update({ lastBetTime, lastUpdatedTime: Date.now() }) })