Last active
December 13, 2021 15:55
-
-
Save matti/6d768b33919100bd1031637051d453bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ss = SpreadsheetApp.openById('1AKPTWbOiRactKDBxc-dA25JgWiXSjwKCK1ivVfa1xnw'); | |
| function minutely() { | |
| run('minutely') | |
| } | |
| function hourly() { | |
| run('hourly') | |
| } | |
| function daily() { | |
| run('daily') | |
| } | |
| function monthly() { | |
| run('monthly') | |
| } | |
| function run(name) { | |
| var sheet = ss.getSheetByName(name) | |
| var now = new Date() | |
| var date = [ | |
| now.toDateString(), | |
| now.toTimeString() | |
| ].join(" ") | |
| var response = UrlFetchApp.fetch("https://explorer.raptoreum.com/api/getnodelist") | |
| var status = response.getResponseCode() | |
| if ( status != 200 ) { | |
| Logger.log(["status", status]) | |
| return | |
| } | |
| var nodes = JSON.parse(response.getContentText()) | |
| var statuses = {} | |
| for (let node of nodes) { | |
| if ( !statuses[node.Status]) { | |
| statuses[node.Status] = 0 | |
| } | |
| statuses[node.Status] = statuses[node.Status] + 1 | |
| } | |
| labels = sheet.getRange('B1:X1').getValues()[0] | |
| row = [now] | |
| for (let label of labels) { | |
| if (label == '') { | |
| break; | |
| } | |
| row.push(statuses[label]) | |
| } | |
| Logger.log(row) | |
| sheet.appendRow(row) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment