From e64792809d074f7652d1769190347118cdf15322 Mon Sep 17 00:00:00 2001 From: techpixel Date: Sat, 27 Apr 2024 20:17:39 -0500 Subject: [PATCH] add admin helper --- src/subroutines/events/powerHour.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/subroutines/events/powerHour.ts b/src/subroutines/events/powerHour.ts index 945d546..03bc8d0 100644 --- a/src/subroutines/events/powerHour.ts +++ b/src/subroutines/events/powerHour.ts @@ -147,6 +147,11 @@ class PowerHour implements BasePicnic { delete eventSessions[forwardTs]; }); + + app.command("/_admin_pwrhr_check", async ({ ack, body }) => { + await ack(); + await this.hourlyCheck(); + }); } async createSession(slackId: string, messageTs: string): Promise { @@ -299,16 +304,16 @@ class PowerHour implements BasePicnic { const eventContributions = await prisma.eventContributions.findMany({ where: { - eventId: POWERHOUR_ID, + eventId: this.ID, }, }); const users = await prisma.user.findMany({ where: { - eventId: POWERHOUR_ID, + eventId: this.ID, }, }); - + let totalMinutes = 0; for (const contribution of eventContributions) { totalMinutes += contribution.minutes; @@ -331,12 +336,12 @@ class PowerHour implements BasePicnic { text: `The community goal of ${this.COMMUNITY_GOAL} minutes was not met. 😢`, }); } - + for (const user of users) { await prisma.user.update({ where: { slackId: user.slackId, - eventId: POWERHOUR_ID, + eventId: this.ID, }, data: { eventId: "none", @@ -347,10 +352,9 @@ class PowerHour implements BasePicnic { console.log("🎉 PowerHour Event Complete"); } - /* if (!this.isEventActive()) { return; - }*/ + } await app.client.chat.postMessage({ channel: Environment.POWERHOUR_ORG,