v1.3.2-beta/URGENT PATCH FIX, clean up fix

This commit is contained in:
Ayushya Amitabh
2020-06-03 22:12:23 -04:00
parent 178c5220d9
commit 7fb38e2b9e
12 changed files with 41 additions and 34 deletions
+11 -4
View File
@@ -1,5 +1,12 @@
const admin = require('firebase-admin');
const FunctionModules = require('./index');
const timeDiff = (ds1, ds2) => {
const d1 = new Date(ds1);
const d2 = new Date(ds2);
var diff = (d2.getTime() - d1.getTime()) / 1000;
diff /= 60 * 60;
return Math.abs(Math.round(diff));
};
module.exports = async () => {
const startedTime = new Date();
@@ -19,10 +26,10 @@ module.exports = async () => {
.get()
.then(async (roomSnap) => {
if (
FunctionModules.timeDiff(roomSnap.createTime.toDate(), startedTime) >= 24 ||
FunctionModules.timeDiff(roomSnap.updateTime.toDate(), startedTime) >= 12
timeDiff(roomSnap.createTime.toDate(), startedTime) >= 24 ||
timeDiff(roomSnap.updateTime.toDate(), startedTime) >= 12
)
await FunctionModules.cleanUpRoom(roomSnap.id);
await FunctionModules2.cleanUpRoom(roomSnap.id);
console.info(`Deleted room ${roomSnap.id} from auto cleanup`);
return;
})
+1 -1
View File
@@ -1,4 +1,4 @@
module.exports = (ds1, ds2) => {
module.exports = function (ds1, ds2) {
const d1 = new Date(ds1);
const d2 = new Date(ds2);
var diff = (d2.getTime() - d1.getTime()) / 1000;