feat(views): list, add, stats
This commit is contained in:
parent
d43e2651c5
commit
8e324b2a1f
27
DESIGN.md
27
DESIGN.md
@ -11,13 +11,15 @@
|
||||
|
||||
# MVP
|
||||
|
||||
- [x] chore: data model
|
||||
- [x] data migration scripts
|
||||
- [ ] homepage
|
||||
- [ ] form to register an instance
|
||||
- [x] form to register an instance
|
||||
- [ ] check for duplicates
|
||||
- [ ] grab first stats : version, users, groups, events
|
||||
- [ ] if fail, set failure to 1
|
||||
- [ ] confirmation page
|
||||
- [ ] instances list, no pagination
|
||||
- [x] instances list, no pagination
|
||||
- [ ] abuse link
|
||||
- [ ] cron
|
||||
- [ ] select instances where failure < max_failure
|
||||
@ -25,13 +27,20 @@
|
||||
- [ ] if fail, set failure to failure+1
|
||||
- [ ] if success, set failure = 0
|
||||
- [ ] stats page
|
||||
- [ ] instances over time area chart
|
||||
- [ ] users over time area chart
|
||||
- [ ] events over time area chart
|
||||
- [ ] groups over time area chart
|
||||
- [ ] versions pie chart
|
||||
- [ ] languages pie chart (user weighted ?)
|
||||
- [ ] location pie chart
|
||||
- [x] big numbers
|
||||
- [x] total Instances
|
||||
- [x] total Users
|
||||
- [x] total Groups
|
||||
- [x] total Events
|
||||
- [x] over time
|
||||
- [x] instances over time area chart
|
||||
- [x] users over time area chart
|
||||
- [x] events over time area chart
|
||||
- [x] groups over time area chart
|
||||
- [ ] repartition
|
||||
- [ ] versions pie chart
|
||||
- [ ] languages pie chart (user weighted ?)
|
||||
- [ ] location pie chart
|
||||
|
||||
|
||||
# impl
|
||||
|
31
add_instance.sql
Normal file
31
add_instance.sql
Normal file
@ -0,0 +1,31 @@
|
||||
-- TODO check for duplicate to avoid
|
||||
-- error returned from database: (code: 2067) UNIQUE constraint failed: instances.domain
|
||||
|
||||
select
|
||||
'alert' as component
|
||||
, 'Error' as title
|
||||
, 'domain must be minimum four characters' as description
|
||||
, 'alert-circle' as icon
|
||||
, 'red' as color
|
||||
where length($domain) <4
|
||||
or $domain is null
|
||||
;
|
||||
|
||||
-- TODO perform better validation of the domain
|
||||
insert into instances(domain, failure) select $domain, -1
|
||||
where length($domain) >3
|
||||
and $domain is not null
|
||||
;
|
||||
|
||||
select
|
||||
'empty_state' as component
|
||||
, 'mood-check' as icon
|
||||
, 'Thanks you' as title
|
||||
, 'This domain ' || $domain || ' has been added to the list and will be be displayed after next refresh, usually once a day' as description
|
||||
, 'Go back to the list' as link_text
|
||||
, 'home' as link_icon
|
||||
, '/' as link
|
||||
where length($domain) >3
|
||||
and $domain is not null
|
||||
;
|
||||
|
41
index.sql
Normal file
41
index.sql
Normal file
@ -0,0 +1,41 @@
|
||||
select
|
||||
'shell' as component
|
||||
, 'Mobilizon Instances' as title
|
||||
, 'social' as icon
|
||||
, '' as footer
|
||||
;
|
||||
|
||||
-- add form
|
||||
select
|
||||
'form' as component
|
||||
, 'GET' as method
|
||||
, 'add an instance' as validate
|
||||
, '/add_instance' as action
|
||||
;
|
||||
select
|
||||
'domain' as name
|
||||
, 70 as maxlength
|
||||
, '[0-9.a-z]{4,70}' as pattern
|
||||
--, 'url' as type
|
||||
, 'events.example.net' as placeholder
|
||||
, true as required
|
||||
, 6 as width
|
||||
;
|
||||
|
||||
-- instances list
|
||||
select
|
||||
'table' as component
|
||||
, true as search
|
||||
, true as small
|
||||
, true as sort
|
||||
, true as freeze_headers
|
||||
, true as striped_rows
|
||||
;
|
||||
select
|
||||
domain as Url
|
||||
, name
|
||||
, slogan
|
||||
, description
|
||||
from instances
|
||||
where failure >= 0
|
||||
;
|
@ -3,6 +3,7 @@ PRAGMA foreign_keys = true;
|
||||
CREATE TABLE instances (
|
||||
-- PK will be rowid
|
||||
domain TEXT UNIQUE
|
||||
, name TEXT
|
||||
, slogan TEXT
|
||||
, description TEXT
|
||||
, languages TEXT
|
||||
|
@ -3,12 +3,14 @@
|
||||
create table instances as select
|
||||
id as rowid
|
||||
, host as domain
|
||||
, config->'description' as slogan
|
||||
, config->'longDescription' as description
|
||||
, config->>'name' as name
|
||||
, '' as slogan
|
||||
, config->>'description' as description
|
||||
-- won't caputure long description, not used yet
|
||||
, languages
|
||||
, CASE WHEN config->'registrationsOpen' = 'true' THEN 1 ELSE 0 END as open
|
||||
, config->'version' as version
|
||||
, "connectivityStats"->'country' as location
|
||||
, config->>'version' as version
|
||||
, "connectivityStats"->>'country' as location
|
||||
, 0 as failure
|
||||
, CAST(extract(epoch from "createdAt") as integer) as "createdAt"
|
||||
, CAST(extract(epoch from "updatedAt") as integer) as "updatedAt"
|
||||
|
114
stats.sql
Normal file
114
stats.sql
Normal file
@ -0,0 +1,114 @@
|
||||
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 sum(users) from ( SELECT
|
||||
instance_id,
|
||||
users,
|
||||
MAX(insertedAt)
|
||||
FROM stats
|
||||
GROUP BY instance_id)) as value
|
||||
;
|
||||
-- total Groups
|
||||
select
|
||||
'Groups' as title
|
||||
, (select sum(local_groups) from ( SELECT
|
||||
instance_id,
|
||||
local_groups,
|
||||
MAX(insertedAt)
|
||||
FROM stats
|
||||
GROUP BY instance_id)) as value
|
||||
;
|
||||
-- total Events
|
||||
select
|
||||
'Events' as title
|
||||
, (select sum(local_events) from ( SELECT
|
||||
instance_id,
|
||||
local_events,
|
||||
MAX(insertedAt)
|
||||
FROM stats
|
||||
GROUP BY instance_id)) 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
|
||||
count(instance_id) as y
|
||||
, insertedAt as x
|
||||
, insertedAt / (3600*24) as j
|
||||
FROM stats
|
||||
GROUP BY j
|
||||
order by j
|
||||
;
|
||||
-- users
|
||||
select
|
||||
'chart' as component
|
||||
, 'Users' as title
|
||||
, 'area' as type
|
||||
, 'blue-lt' as color
|
||||
--, 5 as marker
|
||||
, TRUE as time
|
||||
;
|
||||
SELECT
|
||||
sum(users) as y
|
||||
, insertedAt as x
|
||||
, insertedAt / (3600*24) as j
|
||||
FROM stats
|
||||
GROUP BY j
|
||||
order by j
|
||||
;
|
||||
-- events
|
||||
select
|
||||
'chart' as component
|
||||
, 'Events' as title
|
||||
, 'area' as type
|
||||
, 'blue-lt' as color
|
||||
--, 5 as marker
|
||||
, TRUE as time
|
||||
;
|
||||
SELECT
|
||||
sum(local_events) as y
|
||||
, insertedAt as x
|
||||
, insertedAt / (3600*24) as j
|
||||
FROM stats
|
||||
GROUP BY j
|
||||
order by j
|
||||
;
|
||||
-- groups
|
||||
select
|
||||
'chart' as component
|
||||
, 'Groups' as title
|
||||
, 'area' as type
|
||||
, 'blue-lt' as color
|
||||
--, 5 as marker
|
||||
, TRUE as time
|
||||
;
|
||||
SELECT
|
||||
sum(local_groups) as y
|
||||
, insertedAt as x
|
||||
, insertedAt / (3600*24) as j
|
||||
FROM stats
|
||||
GROUP BY j
|
||||
order by j
|
||||
;
|
Loading…
x
Reference in New Issue
Block a user