Skip to content

Commit

Permalink
switched batch jobs to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bwsarge committed Nov 7, 2023
1 parent 3d94b33 commit fc8aca7
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions functions/src/definitions/batchJobs/batchJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Timestamp } from "firebase-admin/firestore"
import { getCount } from "../common/counters"
import { getThresholds } from "../common/utils"
import { defineString } from "firebase-functions/params"
import { onSchedule } from "firebase-functions/v2/scheduler"

const runtimeEnvironment = defineString("ENVIRONMENT")

Expand Down Expand Up @@ -125,28 +126,32 @@ async function interimPromptHandler() {
}
}

const checkSessionExpiring = functions
.region("asia-southeast1")
.runWith({ secrets: ["WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_TOKEN"] })
.pubsub.schedule("1 * * * *")
.timeZone("Asia/Singapore")
.onRun(checkConversationSessionExpiring)
const checkSessionExpiring = onSchedule(
{
schedule: "1 * * * *",
timeZone: "Asia/Singapore",
secrets: ["WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_TOKEN"],
},
deactivateAndRemind
)

const scheduledDeactivation = functions
.region("asia-southeast1")
.runWith({
const scheduledDeactivation = onSchedule(
{
schedule: "11 20 * * *",
timeZone: "Asia/Singapore",
secrets: ["WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", "WHATSAPP_TOKEN"],
})
.pubsub.schedule("11 20 * * *")
.timeZone("Asia/Singapore")
.onRun(deactivateAndRemind)
},
deactivateAndRemind
)

const sendInterimPrompt = functions
.region("asia-southeast1")
.runWith({ secrets: ["WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_TOKEN"] })
.pubsub.schedule("*/20 * * * *")
.timeZone("Asia/Singapore")
.onRun(interimPromptHandler)
const sendInterimPrompt = onSchedule(
{
schedule: "2,22,42 * * * *",
timeZone: "Asia/Singapore",
secrets: ["WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_TOKEN"],
},
interimPromptHandler
)

export {
checkSessionExpiring,
Expand Down

0 comments on commit fc8aca7

Please sign in to comment.