1
0
mirror of https://github.com/elisspace/FxLifeSheet.git synced 2026-08-29 15:44:00 +00:00

Prefill with API response with empty values

This commit is contained in:
Felix Krause
2019-07-21 14:27:30 -04:00
parent 14a121fe20
commit 7734b5e8a7
2 changed files with 39 additions and 5 deletions

24
web.js
View File

@@ -14,13 +14,31 @@ function initMoodAPI(rawDataSheet, lastRunSheet) {
console.log("Launching up API web server...");
// Periodically refresh the value
var interval = 5 * 60 * 1000;
var keys = ["mood", "sleepDuration", "weight", "dailySteps", "gym"];
var keys = [
"mood",
"sleepDuration",
"weight",
"dailySteps",
"gym",
"macrosCarbs",
"macrosProtein",
"macrosFat",
"weeklyComputerTime",
"weeklyPhoneTime"
];
var _loop_1 = function (i) {
var key = keys[i];
setInterval(function () {
loadCurrentData(key);
}, interval);
loadCurrentData(key);
}, interval + i * 500);
// to avoid rate limits
setInterval(function () {
loadCurrentData(key);
}, i * 250);
lastFetchedData[key] = {
time: null,
value: null
};
};
for (var i = 0; i < keys.length; i++) {
_loop_1(i);

20
web.ts
View File

@@ -17,7 +17,18 @@ function initMoodAPI(rawDataSheet, lastRunSheet) {
// Periodically refresh the value
let interval = 5 * 60 * 1000;
let keys = ["mood", "sleepDuration", "weight", "dailySteps", "gym", "macrosCarbs", "macrosProtein", "macrosFat", "weeklyComputerTime", "weeklyPhoneTime"];
let keys = [
"mood",
"sleepDuration",
"weight",
"dailySteps",
"gym",
"macrosCarbs",
"macrosProtein",
"macrosFat",
"weeklyComputerTime",
"weeklyPhoneTime"
];
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
setInterval(function() {
@@ -27,7 +38,12 @@ function initMoodAPI(rawDataSheet, lastRunSheet) {
// to avoid rate limits
setInterval(function() {
loadCurrentData(key);
}, i * 250)
}, i * 250);
lastFetchedData[key] = {
time: null,
value: null
};
}
http