Skip to content

Commit

Permalink
change log
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sidhdhi-p committed Sep 23, 2024
1 parent 2f880f1 commit 01a40e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion khelo/functions/src/match/match_repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ class MatchRepository {
const startThreshold = new admin.firestore.Timestamp(startThresholdInSeconds, 0);
const endThreshold = new admin.firestore.Timestamp(endThresholdInSeconds, 0);

console.log(`MatchRepository: getting matches within threshold from ${startThreshold.toDate().toLocaleString()} to ${endThreshold.toDate().toLocaleString()}`);

const upcomingMatchesQuery = this.matchRef()
.where("start_at", ">=", startThreshold)
.where("start_at", "<=", endThreshold);
try {
const upcomingMatchesSnapshot = await upcomingMatchesQuery.get();
if (!upcomingMatchesSnapshot.empty) {
console.log(`MatchRepository: ${upcomingMatchesSnapshot.length} upcoming matches found within threshold`);
const promises = upcomingMatchesSnapshot.docs.map(async (matchDoc) => {
const matchData = matchDoc.data();
await this.matchService.notifyBeforeMatchStart(matchData);
});
await Promise.all(promises);
} else {
console.log(`MatchRepository: No upcoming matches found within threshold.from ${startThreshold.toDate().toLocaleString()} to ${endThreshold.toDate().toLocaleString()}`);
console.log("MatchRepository: No upcoming matches found within threshold");
}
} catch (e) {
console.error("MatchRepository: Error getting upcoming matches:", e);
Expand Down

0 comments on commit 01a40e7

Please sign in to comment.