-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_firebase.js
28 lines (23 loc) · 947 Bytes
/
template_firebase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const cron = '44 14 * * *';
// https://crontab.guru/
const region = 'us-east1';
// region needs to be fixed using stackoverflow post
const timeZone = 'America/New_York';
// DO NOT EDIT ANY CODE BELOW THIS LINE
const functions = require("firebase-functions");
const Translator = require("./update_translations.ts")
const config = require("./config.json");
let t = new Translator(config);
// need to make region, cron, and timezone in config
// for setting region in firebase, look at answer by Nick Foden below
// https://stackoverflow.com/questions/58579042/firebase-project-initialization-error-cloud-resource-location-is-not-set-for-th
exports.translations = functions.region(region).pubsub.schedule(cron)
.timeZone(timeZone)
.onRun(async (context) =>{
console.log("every minute")
for (const table of config["tables"]) {
for (const language of table["languages"]){
await t.executeTranslation();
}
}
})