select 
    'shell'                 as component
  , 'Mobilizon statistics' as title
  , 'chart-dots'              as icon
  , JSON('{"title":"Instances list","link":"/", "icon":"social"}') as menu_item
  , JSON('{"link":"mailto:contact@kaihuri.org?subject=report%20an%20instance","title":"Report an instance","icon":"forms"}') as menu_item
  , '' as footer
;

select 
    'big_number'  as component
  , 4             as columns
;
-- total Instances
select 
    'Instances'   as title
  , (select count(*) from instances where failure>=0 and failure<5)          as value
;
-- total Users
select 
    'Users'  as title
  ,  (SELECT u FROM day_stats order by j desc limit 1) as value
;
-- total Groups
select 
    'Groups' as title
  ,  (SELECT g FROM day_stats order by j desc limit 1) as value
;
-- total Events
select 
    'Events' as title
  ,  (SELECT e FROM day_stats order by j desc limit 1) as value
;

----- over time ----
select 
    'title'   as component
  , 'Over time' as contents
;

-- instances
select 
    'chart'             as component
  , 'Instances'  as title
  , 'area'              as type
  , 'blue-lt'           as color
  --, 5                   as marker
  , TRUE                as time
;
SELECT i as y, x FROM day_stats
;
-- users
select 
    'chart'             as component
  , 'Users' as title
  , 'area'              as type
  , 'blue-lt'           as color
  --, 5                   as marker
  , TRUE                as time
;
SELECT u as y, x FROM day_stats
;
-- events
select 
    'chart'             as component
  , 'Events' as title
  , 'area'              as type
  , 'blue-lt'           as color
  --, 5                   as marker
  , TRUE                as time
;
SELECT e as y, x FROM day_stats
;
-- groups
select 
    'chart'             as component
  , 'Groups' as title
  , 'area'              as type
  , 'blue-lt'           as color
  --, 5                   as marker
  , TRUE                as time
;
SELECT g as y, x FROM day_stats
;
