-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating schedule functions. now they are running on europe-west1
- Loading branch information
1 parent
6f77523
commit 0460533
Showing
9 changed files
with
149 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules/ | ||
ServiceAccount/ | ||
functions/firebase-debug.log | ||
.env* | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
const { onSchedule } = require("firebase-functions/v2/scheduler"); | ||
const { getFirestore } = require("firebase-admin/firestore"); | ||
|
||
// when you deploy onSchedul function, just comment awaty setGlobalOptions({ region: "europe-north1" }); at config file. More info at README | ||
exports.updateMonthSecondGen = onSchedule("0 0 1 * *", async (event) => { | ||
await getFirestore() | ||
.collection("Users") | ||
.get() | ||
.then((snap) => { | ||
snap.forEach((doc) => { | ||
doc.ref.update({ total_confirmed_hours: 0, total_hours_month: 0 }); | ||
// onSchedule don't suport region europe-north1. More info at README | ||
exports.updateMonthSecondGen = onSchedule( | ||
{ schedule: "0 0 1 * *", region: "europe-west1" }, | ||
async (event) => { | ||
await getFirestore() | ||
.collection("Users") | ||
.get() | ||
.then((snap) => { | ||
snap.forEach((doc) => { | ||
doc.ref.update({ total_confirmed_hours: 0, total_hours_month: 0 }); | ||
}); | ||
}); | ||
}); | ||
return console.log("Successful reset of time for month and approvedtimes"); | ||
}); | ||
return console.log("Successful reset of time for month and approvedtimes"); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
const { onSchedule } = require("firebase-functions/v2/scheduler"); | ||
const { getFirestore } = require("firebase-admin/firestore"); | ||
|
||
exports.updateYearSecondGen = onSchedule("0 0 1 1 *", async (event) => { | ||
try { | ||
await getFirestore() | ||
.collection("Users") | ||
.get() | ||
.then((snap) => { | ||
snap.forEach((doc) => { | ||
doc.ref.update({ total_hours_year: 0 }); | ||
// onSchedule don't suport region europe-north1. More info at README | ||
exports.updateYearSecondGen = onSchedule( | ||
{ schedule: "0 0 1 1 *", region: "europe-west1" }, | ||
async (event) => { | ||
try { | ||
await getFirestore() | ||
.collection("Users") | ||
.get() | ||
.then((snap) => { | ||
snap.forEach((doc) => { | ||
doc.ref.update({ total_hours_year: 0 }); | ||
}); | ||
}); | ||
}); | ||
return console.log("Successful reset of time for year"); | ||
} catch (error) { | ||
console.error("Error fetching user data:", error); | ||
return console.log("Successful reset of time for year"); | ||
} catch (error) { | ||
console.error("Error fetching user data:", error); | ||
} | ||
} | ||
}); | ||
); |
This file was deleted.
Oops, something went wrong.