From b405bd453a09e43c4708989a318afd1262c916de Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 14 Jun 2022 23:16:02 -0500 Subject: [PATCH] Fix auto resolve markets query --- functions/src/resolve-market.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/src/resolve-market.ts b/functions/src/resolve-market.ts index e1b7fbb3..04fc6ffb 100644 --- a/functions/src/resolve-market.ts +++ b/functions/src/resolve-market.ts @@ -60,12 +60,14 @@ export const autoResolveMarkets = functions.pubsub firestore .collection('contracts') .where('isResolved', '==', false) - .where('closeTime', '>', Date.now()) .where('autoResolutionTime', '<', Date.now()) ) + const closedContracts = contracts.filter( + (c) => c.closeTime && c.closeTime < Date.now() + ) await batchedWaitAll( - contracts.map((contract) => async () => { + closedContracts.map((contract) => async () => { const result = await autoResolve(contract) console.log('resolved', contract.slug, 'result:', result)