added an hour delay
This commit is contained in:
parent
057853d1c5
commit
15d5275a87
16
src/index.js
16
src/index.js
|
@ -73,8 +73,6 @@ app.get('/callback', function(req, res) {
|
|||
access_token = credentials.token;
|
||||
}
|
||||
|
||||
let lap = 0;
|
||||
|
||||
let static_image_url = "https://weather.bangkok.go.th/Images/Radar/radarh.jpg";
|
||||
let animated_image_url = "https://dds.bangkok.go.th/Radar/radar_rain.gif";
|
||||
|
||||
|
@ -86,9 +84,8 @@ app.get('/callback', function(req, res) {
|
|||
await Fetch.save_image(static_image_url, static_radar_path);
|
||||
}
|
||||
|
||||
let post_lap = 0;
|
||||
async function post() {
|
||||
lap += 1;
|
||||
console.log(lap);
|
||||
let raw_date = new Date();
|
||||
|
||||
let curr_static_image_size = fs.statSync(static_radar_path).size;
|
||||
|
@ -98,6 +95,7 @@ app.get('/callback', function(req, res) {
|
|||
console.log("Scanned size: " + fetch_static_image_size);
|
||||
|
||||
if(fetch_static_image_size != curr_static_image_size) {
|
||||
if(post_lap == 0 || post_lap == 12) { // 12 * 5 = 60
|
||||
console.log("File size change detected!");
|
||||
await Fetch.save_image(static_image_url, static_radar_path);
|
||||
await Fetch.save_image(animated_image_url, animated_radar_path);
|
||||
|
@ -122,10 +120,18 @@ app.get('/callback', function(req, res) {
|
|||
|
||||
if(post_note.createdNote) {
|
||||
console.log("Note created!");
|
||||
post_lap++;
|
||||
|
||||
if(post_lap == 12) {
|
||||
post_lap = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Note was not created");
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Skipping post");
|
||||
}
|
||||
} else {
|
||||
console.log("No change in data, go on.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue