-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.sql
More file actions
executable file
·55 lines (43 loc) · 2.31 KB
/
Copy pathindex.sql
File metadata and controls
executable file
·55 lines (43 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-- if no start date is passed, assume it is home page and redirect to current month
SELECT
'redirect' AS component,
'/?t='
|| strftime('%Y-%m', current_date, 'start of month')
|| '&start='
|| date(current_date, 'start of month')
|| '&end='
|| current_date
|| '&pstart='
|| date(current_date, 'start of month', '-1 months')
|| '&pend='
|| date(current_date, '-1 months')
AS link
WHERE $start is null;
-- prepare all variables
SET ctx_json = json_object(
'start' , $start,
'end' , ifnull($end, current_date),
't' , ifnull($t, $start||' - '||$end), -- if no title is passed (eg: called from search), make it up
-- this pstart and pend being null will only happen when search from the form.
-- in that situation, use default: pstart = start - (end-start days)
'pstart' , ifnull($pstart, date($start, concat('-',julianday(ifnull($end, current_date))-julianday($start),' days'))),
'pend' , ifnull($pend,date($start, '-1 days')),
'category' , $category, -- this should be a json array; leaving as null is good
'exclude' , ifnull($exclude, ''),
'payee' , ifnull($payee, ''),
'datagrid' , ifnull($datagrid, '')
);
-- draw menu
SELECT 'dynamic' AS component, sqlpage.run_sql('shell.sql') AS properties;
-- create temp tables for the session - all query sql files below use these.
SELECT 'dynamic' AS component, sqlpage.run_sql('r_add_temp_tables.sql', $ctx_json) AS properties;
-- SELECT 'debug' as component, $ctx_json;
-- page title - need to extract populated t from ctx
SELECT 'title' as component, $ctx_json ->> '$.t' as contents;
-- different components that make up the result dashboard
SELECT 'dynamic' AS component, sqlpage.run_sql('r_bignumber_bar.sql', $ctx_json) AS properties;
SELECT 'dynamic' AS component, sqlpage.run_sql('r_net_chart_by_time.sql', $ctx_json) AS properties;
SELECT 'dynamic' AS component, sqlpage.run_sql('r_net_chart_by_category.sql', $ctx_json) AS properties;
SELECT 'dynamic' AS component, sqlpage.run_sql('r_net_tab_by_week.sql', $ctx_json) AS properties;
SELECT 'dynamic' AS component, sqlpage.run_sql('r_top_n_merchants.sql', $ctx_json) AS properties;
SELECT 'dynamic' AS component, sqlpage.run_sql('r_full_datagrid.sql', $ctx_json) AS properties;