From 77badeeb9905d1ec44ce36e954329627c0546d70 Mon Sep 17 00:00:00 2001 From: Charles Barnes Date: Mon, 27 May 2024 00:14:56 +0000 Subject: [PATCH] update logic for initial retrievals --- .github/workflows/docker-image.yml | 2 +- index.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fc1386b..cea9cd1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,7 +17,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Log in to GitHub Container Registry - run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin - name: Build the Docker image run: docker build . --file Dockerfile --tag ghcr.io/${{ github.repository_owner }}/my-image-name:latest diff --git a/index.ts b/index.ts index da49304..ed5fc39 100644 --- a/index.ts +++ b/index.ts @@ -100,7 +100,6 @@ async function fetchUpcomingLeagueEvents(leagueId: string, notifyRoleId: string, eventId: event.idEvent, eventName: event.strEvent, eventDate: gameDate, - notified: false, leagueId, notifyRoleId, channelId: leagueChannelId, @@ -153,7 +152,13 @@ async function checkDatabaseForNotifications() { const tenMinutesFromNow = new Date((new Date()).getTime() + 600000); try { - const games = await gamesCollection.find({ eventDate: { $gte: tenMinutesAgo, $lte: tenMinutesFromNow }, notified: false }).toArray(); + const games = await gamesCollection.find({ + eventDate: { $gte: tenMinutesAgo, $lte: tenMinutesFromNow }, + $or: [ + { notified: { $exists: false } }, + { notified: false } + ] + }).toArray(); for (const game of games) { const channel = client.channels.cache.get(game.channelId!) as TextChannel; if (channel) {