git ssb

0+

Dominic / weather



Commit 99f5ab74ade99cac40ddc23f4f15f26d7c99fd4b

aggregation logs every 10 seconds

Dominic Tarr committed on 9/24/2018, 8:23:21 AM
Parent: 8b77d1c1cfb68a98aae007dcf1ca78189c1dd0be

Files changed

db.jschanged
db.jsView
@@ -84,18 +84,21 @@
8484
8585 var ts = Date.now()
8686
8787 function reduce (state, forecast) {
88 + state = state || {}
8889 var fstate = state[forecast.name] = state[forecast.name] || {}
8990 var wstate = fstate[forecast.month] = fstate[forecast.month] || {winds: {}, count: 0}
9091 forecast.winds.forEach(function (w) {
9192 var wind = w.direction+' '+w.strength
9293 wstate.winds[wind] = (wstate[wind] || 0) + 1
9394 wstate.count ++
9495 })
9596
96- if(Date.now() > ts + 10000)
97 + if(Date.now() > ts + 10000) {
98 + ts = Date.now()
9799 console.error(JSON.stringify(state, null, 2))
100 + }
98101 return state
99102 }
100103
101104 var summary_data
@@ -123,8 +126,8 @@
123126 module.exports = db
124127
125128 if(!module.parent)
126129 db.summary(function (err, data) {
127- console.log(data)
130 + console.log(JSON.stringify(data, null, 2))
128131 })
129132
130133

Built with git-ssb-web