forked from aeroniemi/tmtv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (19 loc) · 709 Bytes
/
index.js
File metadata and controls
21 lines (19 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let activities = require("./activities.js")
const maxAge = 1000 * 60 * 1
// activities.downloadLatestData.then(
// function (value) { console.log(value) },
// function (error) { console.log(error) }
// )
setInterval(() => activities.getNewest().then(
function (newest) {
let lastUpdated = new Date(newest * 1000);
let age = Date.now() - lastUpdated
if (age > maxAge) {
console.log(`it's too old: ${Math.round(age / (1000 * 60))} minutes ago`)
activities.downloadLatestData()
} else {
console.log(`last updated ${Math.round(age / (1000))} seconds ago`)
}
},
function (error) { console.log(error) }
), 30 * 1000)