-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.sql
More file actions
executable file
·70 lines (50 loc) · 2.06 KB
/
index.sql
File metadata and controls
executable file
·70 lines (50 loc) · 2.06 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
SELECT 'title' AS component, 'My Disc Golf Bag' AS title;
SELECT 'list' AS component, 3 AS columns, 'No discs found' AS empty_title;
SELECT
d.name AS title,
'Brand: ' || b.brand_name || E'\n\n' ||
'Type: ' || t.type_name || E'\n\n' ||
'Speed: ' || d.speed || E'\n' ||
'Glide: ' || d.glide || E'\n' ||
'Turn: ' || d.turn || E'\n' ||
'Fade: ' || d.fade AS description_md,
'edit_disc.sql?disc_id=' || d.id AS edit_link,
'delete_disc.sql?disc_id=' || d.id AS delete_link
FROM discs d
JOIN brands b ON d.brand_id = b.id
JOIN disc_types t ON d.type_id = t.id;
SELECT 'form' AS component,
'Add a New Disc' AS title,
'create_disc.sql' AS action;
SELECT 'Disc_Name' AS name, 'text' AS type, 'Disc Name' AS label, TRUE AS required;
SELECT 'Disc_Brand' AS name, 'select' AS type, 'Select a brand' AS label, TRUE AS required,
jsonb_agg(jsonb_build_object('value', id::text, 'label', brand_name)) AS options
FROM brands;
SELECT 'Disc_Type' AS name, 'select' AS type, 'Select disc type' AS label, TRUE AS required,
jsonb_agg(jsonb_build_object('value', id::text, 'label', type_name)) AS options
FROM disc_types;
SELECT 'Speed' AS name, 'number' AS type, 'Speed (1-14)' AS label, TRUE AS required, 1 AS min, 14 AS max;
SELECT 'Glide' AS name, 'number' AS type, 'Glide (1-7)' AS label, TRUE AS required, 1 AS min, 7 AS max;
SELECT 'Turn' AS name, 'number' AS type, 'Turn (-5 to 1)' AS label, TRUE AS required, -5 AS min, 1 AS max;
SELECT 'Fade' AS name, 'number' AS type, 'Fade (0-5)' AS label, TRUE AS required, 0 AS min, 5 AS max;
SELECT 'Submit' AS validate, 'blue' AS validate_color;
SELECT
'chart' AS component,
'Disc Flight Analysis' AS title,
'scatter' AS type,
'Turn + Fade' AS xtitle,
'Speed' AS ytitle,
500 AS height,
6 AS marker,
-5 AS xmin,
5 AS xmax,
0 AS ymin,
14 AS ymax,
1 AS xticks,
2 AS yticks;
SELECT
d.name AS series,
(d.turn + d.fade) AS x, -- X-axis based on Turn + Fade
d.speed AS y, -- Y-axis is Speed
d.name AS label
FROM discs d;