mirror of
https://github.com/sensebox/opensensmapr
synced 2025-02-23 16:23:58 +01:00
add boxes$lastActive distribution to monitor
This commit is contained in:
parent
51595f1239
commit
4501704e75
1 changed files with 12 additions and 0 deletions
|
@ -7,6 +7,10 @@ if (is.null(as.list(environment())$osem_boxes_ts))
|
|||
|
||||
b = osem_boxes()
|
||||
|
||||
# for $`active` computations
|
||||
diffNow = (opensensmapr:::utc_date(Sys.time()) - b$lastMeasurement) %>% as.numeric(unit='hours')
|
||||
neverActive = b[is.na(b$lastMeasurement), ] %>% nrow()
|
||||
|
||||
# only keep aggregated data
|
||||
b_agg = data.frame(time = Sys.time(), boxcount = nrow(b))
|
||||
b_agg$model = b$model %>% table() %>% as.list() %>% list()
|
||||
|
@ -14,6 +18,14 @@ b_agg$exposure = b$exposure %>% table() %>% as.list() %>% list()
|
|||
b_agg$geometry = b %>% osem_as_sf() %>% st_geometry() %>% list()
|
||||
b_agg$phenomena = b %>% osem_phenomena() %>% list()
|
||||
|
||||
b_agg$active = list(
|
||||
'never' = neverActive,
|
||||
'1h' = nrow(b[diffNow <= 1, ]) - neverActive,
|
||||
'1d' = nrow(b[diffNow <= 24, ]) - neverActive,
|
||||
'30d' = nrow(b[diffNow <= 720, ]) - neverActive,
|
||||
'365d' = nrow(b[diffNow <= 8760, ]) - neverActive
|
||||
) %>% list()
|
||||
|
||||
# combine with existing time series
|
||||
osem_boxes_ts = rbind(b_agg, osem_boxes_ts)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue