Commit 99f5ab74ade99cac40ddc23f4f15f26d7c99fd4b
aggregation logs every 10 seconds
Dominic Tarr committed on 9/24/2018, 8:23:21 AMParent: 8b77d1c1cfb68a98aae007dcf1ca78189c1dd0be
Files changed
db.js | changed |
db.js | |||
---|---|---|---|
@@ -84,18 +84,21 @@ | |||
84 | 84 … | ||
85 | 85 … | var ts = Date.now() | |
86 | 86 … | ||
87 | 87 … | function reduce (state, forecast) { | |
88 … | + state = state || {} | ||
88 | 89 … | var fstate = state[forecast.name] = state[forecast.name] || {} | |
89 | 90 … | var wstate = fstate[forecast.month] = fstate[forecast.month] || {winds: {}, count: 0} | |
90 | 91 … | forecast.winds.forEach(function (w) { | |
91 | 92 … | var wind = w.direction+' '+w.strength | |
92 | 93 … | wstate.winds[wind] = (wstate[wind] || 0) + 1 | |
93 | 94 … | wstate.count ++ | |
94 | 95 … | }) | |
95 | 96 … | ||
96 | - if(Date.now() > ts + 10000) | ||
97 … | + if(Date.now() > ts + 10000) { | ||
98 … | + ts = Date.now() | ||
97 | 99 … | console.error(JSON.stringify(state, null, 2)) | |
100 … | + } | ||
98 | 101 … | return state | |
99 | 102 … | } | |
100 | 103 … | ||
101 | 104 … | var summary_data | |
@@ -123,8 +126,8 @@ | |||
123 | 126 … | module.exports = db | |
124 | 127 … | ||
125 | 128 … | if(!module.parent) | |
126 | 129 … | db.summary(function (err, data) { | |
127 | - console.log(data) | ||
130 … | + console.log(JSON.stringify(data, null, 2)) | ||
128 | 131 … | }) | |
129 | 132 … | ||
130 | 133 … |
Built with git-ssb-web