@composable-os/pack-programs 0.0.0-stage → 0.1.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +109 -0
- package/dist/authoring.d.ts +47 -0
- package/dist/authoring.js +493 -0
- package/dist/blocks/programs-bank/exercise-bank.d.ts +4 -0
- package/dist/blocks/programs-bank/exercise-bank.js +68 -0
- package/dist/blocks/programs-builder/program-builder.d.ts +26 -0
- package/dist/blocks/programs-builder/program-builder.js +295 -0
- package/dist/blocks/programs-class-today/class-today.d.ts +6 -0
- package/dist/blocks/programs-class-today/class-today.js +15 -0
- package/dist/blocks/programs-coach-client/coach-client.d.ts +5 -0
- package/dist/blocks/programs-coach-client/coach-client.js +10 -0
- package/dist/blocks/programs-native-class-today/class-today-screen.d.ts +6 -0
- package/dist/blocks/programs-native-class-today/class-today-screen.js +14 -0
- package/dist/blocks/programs-native-coach-client/coach-client-screen.d.ts +7 -0
- package/dist/blocks/programs-native-coach-client/coach-client-screen.js +9 -0
- package/dist/blocks/programs-native-progress/progress-screen.d.ts +5 -0
- package/dist/blocks/programs-native-progress/progress-screen.js +31 -0
- package/dist/blocks/programs-native-session/session-screen.d.ts +7 -0
- package/dist/blocks/programs-native-session/session-screen.js +130 -0
- package/dist/blocks/programs-native-today/today-screen.d.ts +7 -0
- package/dist/blocks/programs-native-today/today-screen.js +11 -0
- package/dist/blocks/programs-progress/progress.d.ts +10 -0
- package/dist/blocks/programs-progress/progress.js +40 -0
- package/dist/blocks/programs-session/session-view.d.ts +9 -0
- package/dist/blocks/programs-session/session-view.js +116 -0
- package/dist/blocks/programs-today/today.d.ts +7 -0
- package/dist/blocks/programs-today/today.js +16 -0
- package/dist/client/index.d.ts +1723 -0
- package/dist/client/index.js +779 -0
- package/dist/dashboards.d.ts +5 -0
- package/dist/dashboards.js +145 -0
- package/dist/index.d.ts +1181 -0
- package/dist/index.js +608 -0
- package/dist/layout.d.ts +88 -0
- package/dist/layout.js +268 -0
- package/dist/tools.d.ts +344 -0
- package/dist/tools.js +930 -0
- package/package.json +36 -4
- package/README.md +0 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const IN = (column) => `${column} >= :date_from AND ${column} < :date_to`;
|
|
2
|
+
/** A week: the Monday it starts on. */
|
|
3
|
+
const WEEK = (column) => `date(${column}, '-' || ((strftime('%w', ${column}) + 6) % 7) || ' days')`;
|
|
4
|
+
export const training = {
|
|
5
|
+
title: "Training",
|
|
6
|
+
description: "Sessions planned against done, sets logged by week, the most used exercises, and clients " +
|
|
7
|
+
"with nothing logged in two weeks.",
|
|
8
|
+
filters: [{ type: "dateRange", id: "date", label: "Dates", default: "this_quarter" }],
|
|
9
|
+
widgets: [
|
|
10
|
+
{
|
|
11
|
+
id: "planned",
|
|
12
|
+
type: "kpi",
|
|
13
|
+
title: "Sessions planned",
|
|
14
|
+
description: "Clients' own sessions dated in the period (classes not counted).",
|
|
15
|
+
sql: `SELECT count(*) AS value FROM rec_x_programs_session s
|
|
16
|
+
WHERE s.kind = 'personal' AND ${IN("s.date")}`,
|
|
17
|
+
mapping: { value: "value" },
|
|
18
|
+
options: { compare: true },
|
|
19
|
+
clickThrough: {
|
|
20
|
+
object: "programs.session",
|
|
21
|
+
filter: {
|
|
22
|
+
and: [
|
|
23
|
+
{ field: "kind", op: "eq", value: "personal" },
|
|
24
|
+
{ field: "date", op: "gte", value: { $param: "date_from" } },
|
|
25
|
+
{ field: "date", op: "lt", value: { $param: "date_to" } },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
layout: { w: 3, h: 1 },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "done",
|
|
33
|
+
type: "kpi",
|
|
34
|
+
title: "Sessions done",
|
|
35
|
+
description: "Of those, the ones marked done.",
|
|
36
|
+
sql: `SELECT count(*) AS value FROM rec_x_programs_session s
|
|
37
|
+
WHERE s.kind = 'personal' AND s.state = 'done' AND ${IN("s.date")}`,
|
|
38
|
+
mapping: { value: "value" },
|
|
39
|
+
options: { compare: true },
|
|
40
|
+
clickThrough: {
|
|
41
|
+
object: "programs.session",
|
|
42
|
+
filter: {
|
|
43
|
+
and: [
|
|
44
|
+
{ field: "kind", op: "eq", value: "personal" },
|
|
45
|
+
{ field: "state", op: "eq", value: "done" },
|
|
46
|
+
{ field: "date", op: "gte", value: { $param: "date_from" } },
|
|
47
|
+
{ field: "date", op: "lt", value: { $param: "date_to" } },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
layout: { w: 3, h: 1 },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "sets",
|
|
55
|
+
type: "kpi",
|
|
56
|
+
title: "Sets logged",
|
|
57
|
+
description: "Sets logged on sessions dated in the period, by clients and in classes.",
|
|
58
|
+
sql: `SELECT count(*) AS value FROM rec_x_programs_log l WHERE ${IN("l.date")}`,
|
|
59
|
+
mapping: { value: "value" },
|
|
60
|
+
options: { compare: true },
|
|
61
|
+
clickThrough: {
|
|
62
|
+
object: "programs.log",
|
|
63
|
+
filter: {
|
|
64
|
+
and: [
|
|
65
|
+
{ field: "date", op: "gte", value: { $param: "date_from" } },
|
|
66
|
+
{ field: "date", op: "lt", value: { $param: "date_to" } },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
layout: { w: 3, h: 1 },
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "quiet-count",
|
|
74
|
+
type: "kpi",
|
|
75
|
+
title: "Clients quiet for two weeks",
|
|
76
|
+
description: "Clients with an active program and no set logged in the last 14 days.",
|
|
77
|
+
sql: `SELECT count(DISTINCT a.person) AS value FROM rec_x_programs_assignment a
|
|
78
|
+
WHERE a.kind = 'personal' AND a.state = 'active' AND NOT EXISTS (
|
|
79
|
+
SELECT 1 FROM rec_x_programs_log l WHERE l.person = a.person AND l.date >= date(:today, '-14 days'))`,
|
|
80
|
+
mapping: { value: "value" },
|
|
81
|
+
options: { compare: false },
|
|
82
|
+
layout: { w: 3, h: 1 },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "planned-done",
|
|
86
|
+
type: "bar",
|
|
87
|
+
title: "Planned and done, by week",
|
|
88
|
+
description: "Clients' own sessions per week of the period: planned, done and skipped.",
|
|
89
|
+
sql: `SELECT ${WEEK("s.date")} AS week, count(*) AS planned,
|
|
90
|
+
sum(CASE WHEN s.state = 'done' THEN 1 ELSE 0 END) AS done,
|
|
91
|
+
sum(CASE WHEN s.state = 'skipped' THEN 1 ELSE 0 END) AS skipped
|
|
92
|
+
FROM rec_x_programs_session s WHERE s.kind = 'personal' AND ${IN("s.date")}
|
|
93
|
+
GROUP BY week ORDER BY week`,
|
|
94
|
+
mapping: { x: "week", y: ["planned", "done", "skipped"] },
|
|
95
|
+
layout: { w: 6, h: 2 },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "sets-by-week",
|
|
99
|
+
type: "line",
|
|
100
|
+
title: "Sets logged by week",
|
|
101
|
+
description: "Sets logged per week of the period, by their session's date.",
|
|
102
|
+
sql: `SELECT ${WEEK("l.date")} AS week, count(*) AS sets
|
|
103
|
+
FROM rec_x_programs_log l WHERE ${IN("l.date")} GROUP BY week ORDER BY week`,
|
|
104
|
+
mapping: { x: "week", y: ["sets"] },
|
|
105
|
+
layout: { w: 6, h: 2 },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "exercises",
|
|
109
|
+
type: "leaderboard",
|
|
110
|
+
title: "Most used exercises",
|
|
111
|
+
description: "Exercises by sets logged in the period.",
|
|
112
|
+
sql: `SELECT e.id AS exercise_id, e.name AS label, count(*) AS value
|
|
113
|
+
FROM rec_x_programs_log l JOIN rec_x_programs_exercise e ON e.id = l.exercise
|
|
114
|
+
WHERE ${IN("l.date")} GROUP BY e.id, e.name ORDER BY value DESC, label LIMIT 10`,
|
|
115
|
+
mapping: { label: "label", value: "value" },
|
|
116
|
+
clickThrough: {
|
|
117
|
+
object: "programs.log",
|
|
118
|
+
filter: {
|
|
119
|
+
and: [
|
|
120
|
+
{ field: "exercise", op: "eq", value: { $row: "exercise_id" } },
|
|
121
|
+
{ field: "date", op: "gte", value: { $param: "date_from" } },
|
|
122
|
+
{ field: "date", op: "lt", value: { $param: "date_to" } },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
layout: { w: 6, h: 2 },
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "quiet",
|
|
130
|
+
type: "table",
|
|
131
|
+
title: "Nothing logged in two weeks",
|
|
132
|
+
description: "Clients with an active program and no set logged in the last 14 days, with their last set.",
|
|
133
|
+
sql: `SELECT p.id AS id, p.display_name AS client, a.title AS program,
|
|
134
|
+
(SELECT max(l.date) FROM rec_x_programs_log l WHERE l.person = a.person) AS last_logged
|
|
135
|
+
FROM rec_x_programs_assignment a JOIN rec_person p ON p.id = a.person
|
|
136
|
+
WHERE a.kind = 'personal' AND a.state = 'active' AND NOT EXISTS (
|
|
137
|
+
SELECT 1 FROM rec_x_programs_log l WHERE l.person = a.person AND l.date >= date(:today, '-14 days'))
|
|
138
|
+
ORDER BY last_logged, client LIMIT 50`,
|
|
139
|
+
mapping: { columns: ["client", "program", "last_logged"] },
|
|
140
|
+
clickThrough: { object: "person", filter: { field: "id", op: "eq", value: { $row: "id" } } },
|
|
141
|
+
layout: { w: 6, h: 2 },
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
export const programsDashboards = { training };
|