-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrabMidjourneyQuery.js
42 lines (33 loc) · 1.35 KB
/
grabMidjourneyQuery.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require('dotenv').config({ path: __dirname + '/.env' })
var genErrorPage = require('./utility/genErrorPage.js');
const { initializeApp, applicationDefault, cert } = require('firebase-admin/app');
const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
const serviceAccount = require('/Users/mikeland/WeatherWindow/config/' + process.env.SERVICE_FILE_NAME);
// const serviceAccount = require('/Users/mikeland/newDay/WeatherWindow/config/' + process.env.SERVICE_FILE_NAME);
initializeApp({
credential: cert(serviceAccount)
});
const db = getFirestore();
(async () => {
try {
var queryPkg;
var pendingQueries = await db.collection("WeatherWindowQueries").where("midjourneyImage", "==", "PENDING").limit(1).get();
pendingQueries.forEach(queryDoc => {
queryPkg = queryDoc.data();
queryPkg.id = queryDoc.id;
})
if (!queryPkg) {
console.log("No PENDING queries found");
process.exit(1);
}
console.log("Midjourney Query Found")
console.log("\"" + queryPkg.query + "\"");
await db.collection("WeatherWindowQueries").doc(queryPkg.id).update({
midjourneyImage:"PROCESSING"
})
process.exit(0);
} catch (err) {
console.log(err);
await genErrorPage.gen(err);
}
})();