@stamhoofd/metabase 2.148.0 → 2.150.0
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/README.md +74 -33
- package/dist/api.d.ts +28 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +27 -0
- package/dist/api.js.map +1 -1
- package/dist/report.d.ts +51 -4
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +75 -17
- package/dist/report.js.map +1 -1
- package/dist/sync-report.d.ts +54 -14
- package/dist/sync-report.d.ts.map +1 -1
- package/dist/sync-report.js +87 -15
- package/dist/sync-report.js.map +1 -1
- package/package.json +3 -3
- package/report/eenheden.sql +218 -173
- package/report/filters.sql +11 -41
- package/report/includes/all-non-platform-registrations-all-years.sql +58 -0
- package/report/includes/all-non-platform-registrations.sql +10 -0
- package/report/includes/all-registrations.sql +53 -0
- package/report/includes/child-leader-ratio.sql +4 -0
- package/report/includes/deduplicated-non-platform-registrations-all-years.sql +30 -0
- package/report/includes/deduplicated-non-platform-registrations.sql +30 -0
- package/report/includes/default-age-group-category.sql +2 -0
- package/report/includes/default-age-groups-with-category.sql +10 -0
- package/report/includes/filter-delivery-memberships.sql +2 -0
- package/report/includes/filter-has-delivery-membership.sql +11 -0
- package/report/includes/filter-registration-types.sql +2 -0
- package/report/includes/filter-statistics-memberships.sql +2 -0
- package/report/includes/gtp.sql +10 -48
- package/report/includes/keeo/{tak-categorie.sql → default-age-group-category.sql} +2 -15
- package/report/includes/keeo/filter-delivery-memberships.sql +5 -0
- package/report/includes/keeo/filter-statistics-memberships.sql +5 -0
- package/report/includes/members-per-year.sql +26 -0
- package/report/includes/membership-fee-type.sql +5 -0
- package/report/includes/participant-type.sql +2 -0
- package/report/includes/postal-code-coordinates.sql +2 -0
- package/report/includes/ravot/child-leader-ratio.sql +4 -0
- package/report/includes/ravot/default-age-group-category.sql +15 -0
- package/report/includes/ravot/filter-delivery-memberships.sql +4 -0
- package/report/includes/ravot/filter-statistics-memberships.sql +4 -0
- package/report/includes/ravot/gtp.sql +8 -29
- package/report/includes/ravot/participant-type.sql +7 -0
- package/report/includes/uldk.sql +16 -22
- package/report/includes/years-with-members.sql +11 -0
- package/report/jeugdbewegingen.sql +60 -167
- package/report/nationaal.sql +105 -81
- package/report/netwerk.sql +46 -34
- package/report/varia.sql +11 -9
- package/report/includes/aangesloten.sql +0 -23
- package/report/includes/aansluiting.sql +0 -26
- package/report/includes/facts-alle-jaren.sql +0 -53
- package/report/includes/facts.sql +0 -102
- package/report/includes/ingeschreven-voor.sql +0 -27
- package/report/includes/jaren.sql +0 -20
- package/report/includes/leden-per-jaar.sql +0 -29
- package/report/includes/leden.sql +0 -39
- package/report/includes/omkaderingscijfer.sql +0 -17
- package/report/includes/postcode-coordinaten.sql +0 -8
- package/report/includes/ravot/omkaderingscijfer.sql +0 -25
- package/report/includes/ravot/tak-categorie.sql +0 -28
- package/report/includes/ravot/type-deelnemers.sql +0 -22
- package/report/includes/tak-categorie.sql +0 -18
- package/report/includes/takken.sql +0 -20
- package/report/includes/tarief.sql +0 -14
- package/report/includes/type-deelnemers.sql +0 -14
package/README.md
CHANGED
|
@@ -12,35 +12,72 @@ Everything that configures Metabase: the ledenstatistieken report and the API cl
|
|
|
12
12
|
|
|
13
13
|
## What the report counts
|
|
14
14
|
|
|
15
|
-
Two fragments decide that, and every card opens
|
|
15
|
+
Two fragments decide that, and every card opens on one of them:
|
|
16
16
|
|
|
17
17
|
| | |
|
|
18
18
|
|---|---|
|
|
19
|
-
| `includes/
|
|
20
|
-
| `includes/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
| `includes/all-non-platform-registrations.sql` | one row per registration: who was registered where, in which leeftijdsgroep, in which year |
|
|
20
|
+
| `includes/deduplicated-non-platform-registrations.sql` | that narrowed to one row per member per eenheid, carrying what they are |
|
|
21
|
+
|
|
22
|
+
Each fragment is a complete query. It states its own dependencies -- `deduplicated-non-platform-registrations` opens a `WITH` on
|
|
23
|
+
`all-non-platform-registrations`, which opens one on `all-registrations` -- so whoever reads one
|
|
24
|
+
includes that one and nothing else, names it in a `WITH` (or a derived table) of their own, and never
|
|
25
|
+
learns what it is built from. It also means every fragment runs as it stands: paste
|
|
26
|
+
`{{snippet: deduplicated-non-platform-registrations}}` into a Metabase question on its own and the leden come back as a table, which is
|
|
27
|
+
how a figure is investigated apart from the aggregates the cards draw over it.
|
|
28
|
+
`includes/deduplicated-non-platform-registrations-all-years.sql` is the same over every werkjaar at once -- the year filter does not
|
|
29
|
+
reach it, which is what the trend cards read; a test keeps its ranking identical to the single-year fragment's.
|
|
30
|
+
|
|
31
|
+
A fragment that is a condition rather than a query -- which aansluitingen count, which kinds of
|
|
32
|
+
registration count -- carries a `filter-` prefix and is a bare predicate: the query that includes it
|
|
33
|
+
writes the `AND` or `WHERE` around it, so it fits any place in a where-clause. A fragment says what
|
|
34
|
+
it is on a `-- description:` first line, which becomes the snippet's description in Metabase rather
|
|
35
|
+
than a comment in its sql.
|
|
36
|
+
|
|
37
|
+
The ledenstatistieken count members, not registrations, so every card of that dashboard reads `deduplicated-non-platform-registrations`
|
|
38
|
+
and none reads the registrations directly. Someone registered in two leeftijdsgroepen of the same eenheid holds
|
|
39
|
+
two registrations, and counted there they land in two bars of the same chart, or -- if they are leiding in one
|
|
40
|
+
leeftijdsgroep and lid in the other -- on both sides of the omkaderingscijfer at once. That fragment picks the one
|
|
41
|
+
registration that speaks for them: leiding beats lid, and the oldest leeftijdsgroep wins between two.
|
|
27
42
|
|
|
28
43
|
The aanlevering is the exception and keeps reading its own rows. The department counts inschrijvingen
|
|
29
44
|
rather than inschrijvers, and reads what a member is from the cancelled registrations as well, so
|
|
30
45
|
`jeugdbewegingen.sql` decides it in its own `deelnemers`.
|
|
31
46
|
|
|
32
|
-
Which registrations reach either of those is
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
Which registrations reach either of those is `includes/filter-registration-types.sql`: a registration
|
|
48
|
+
stands in a leeftijdsgroep, an activiteit or a wachtlijst, and only the first two count as being a
|
|
49
|
+
lid -- counting the wachtlijsten would put the people waiting for a place among the leden. The
|
|
50
|
+
aanlevering pins itself further to the leeftijdsgroepen alone in `jeugdbewegingen.sql`.
|
|
51
|
+
|
|
52
|
+
## One definition, in Metabase too
|
|
53
|
+
|
|
54
|
+
`@include` puts a fragment in one place in git. Snippets put it in one place in Metabase: every
|
|
55
|
+
`includes/*.sql` is written as a snippet of its own, and a question refers to it -- `{{snippet: deduplicated-non-platform-registrations}}`
|
|
56
|
+
where the file says `-- @include deduplicated-non-platform-registrations`, with it referring to
|
|
57
|
+
`{{snippet: all-non-platform-registrations}}` rather than holding a second copy of those rows. A card is then the handful of lines that say what it counts
|
|
58
|
+
instead of the two hundred that say what a lid is, and whoever changes what a lid is changes it once
|
|
59
|
+
for the forty-odd questions that count one -- the questions the client writes themselves included,
|
|
60
|
+
which can open on `{{snippet: deduplicated-non-platform-registrations}}` instead of on a copy pasted out of a card.
|
|
61
|
+
|
|
62
|
+
A question declares a tag for every fragment it reads, the ones it only reaches through another
|
|
63
|
+
fragment included: Metabase resolves a nested `{{snippet: all-registrations}}` against the tags of the question
|
|
64
|
+
it is running and not against those of the fragment that refers to it, so naming a fragment is not enough
|
|
65
|
+
to reach what it reads. A snippet is also pointed at by id, which is why the fragments are
|
|
66
|
+
written before the questions that read them.
|
|
67
|
+
|
|
68
|
+
Nothing here ever clears a fragment away. Metabase cannot delete a snippet, only archive it, and the
|
|
69
|
+
name stays taken either way -- so a snippet is matched by name and updated in place, an archived one
|
|
70
|
+
is brought back rather than written a second time, and one the report no longer has is left alone,
|
|
71
|
+
since whatever has been built on it since would break with it.
|
|
72
|
+
|
|
73
|
+
The fragments are still expanded as well. `card.sql` is the whole query, which is what the tests read
|
|
74
|
+
and what says whether the sql itself is right; `card.snippetSql` is that query with the fragments left
|
|
75
|
+
as references, and is what Metabase is given.
|
|
39
76
|
|
|
40
77
|
## One report, several platforms
|
|
41
78
|
|
|
42
79
|
The same report is written for every platform, and they do not all count every figure the same way:
|
|
43
|
-
the GTP index weighs
|
|
80
|
+
the GTP index weighs leeftijdsgroepen for keeo and the age of a lid for ravot, where leiding count as one and a
|
|
44
81
|
half. A statistics database holds one platform, so which variant a card gets is decided while the
|
|
45
82
|
report is loaded — `loadReport(env)` takes the environment, the same name the data source carries.
|
|
46
83
|
|
|
@@ -53,29 +90,29 @@ A card names neither and keeps saying `@include gtp`, which is what keeps one re
|
|
|
53
90
|
becoming two. An override of a name no fragment carries is refused rather than ignored: nothing
|
|
54
91
|
includes it, so a misspelled file would change nothing and say nothing.
|
|
55
92
|
|
|
56
|
-
## What a
|
|
93
|
+
## What a leeftijdsgroep counts as
|
|
57
94
|
|
|
58
95
|
Kinderen, leiding or volwassenen. Every figure that divides the one from the other reads it, and it
|
|
59
|
-
is the one thing about a
|
|
60
|
-
no such field, and the ages do not answer it, since leiding and stam carry no age range and a
|
|
96
|
+
is the one thing about a leeftijdsgroep that nothing in the administration knows: the platform configuration has
|
|
97
|
+
no such field, and the ages do not answer it, since leiding and stam carry no age range and a leeftijdsgroep of
|
|
61
98
|
kinderen need not carry one either.
|
|
62
99
|
|
|
63
|
-
`includes/
|
|
64
|
-
`includes/
|
|
65
|
-
|
|
66
|
-
is left with.
|
|
100
|
+
`includes/default-age-groups-with-category.sql` is where it is settled, and
|
|
101
|
+
`includes/default-age-group-category.sql` is the answer itself. `includes/keeo/` and
|
|
102
|
+
`includes/ravot/` hold the lists that name that platform's leeftijdsgroepen by id; the unqualified fragment
|
|
103
|
+
says nothing, which is what a platform that has not written its list is left with.
|
|
67
104
|
|
|
68
105
|
The statistics database used to hold a hand-filled `category` column for this instead. It is dropped:
|
|
69
106
|
a column no rebuild survives, refilled by an UPDATE recorded nowhere, is not somewhere an answer can
|
|
70
107
|
live. A list in the query is in git, is checked by the tests, and stands in front of whoever opens
|
|
71
|
-
the question in Metabase. The cost is that it is now the whole answer — a
|
|
72
|
-
platform's list counts as nothing at all, so a
|
|
108
|
+
the question in Metabase. The cost is that it is now the whole answer — a leeftijdsgroep missing from its
|
|
109
|
+
platform's list counts as nothing at all, so a leeftijdsgroep added to the platform configuration has to be
|
|
73
110
|
added here too.
|
|
74
111
|
|
|
75
112
|
Ravot's list is the one to read before changing either. Its ondersteunende leden are volwassenen and
|
|
76
113
|
may not be categorised as leiding: the omkaderingscijfer and the GTP index would then count them as
|
|
77
114
|
leiding the kinderen of an eenheid are looked after by. The aanlevering delivers them among the
|
|
78
|
-
leiding anyway — the department has no third word for them — by naming the
|
|
115
|
+
leiding anyway — the department has no third word for them — by naming the leeftijdsgroep itself in
|
|
79
116
|
`ravot/type-deelnemers.sql`, which only works for as long as the category does not say it.
|
|
80
117
|
|
|
81
118
|
Standing in front of the reader only holds until the next `yarn metabase report`, which rewrites every
|
|
@@ -91,12 +128,16 @@ header of an export from the column's title, and a sheet read by a government de
|
|
|
91
128
|
the names the template gives it.
|
|
92
129
|
|
|
93
130
|
The koepel's own organization is treated the other way around by the two. The ledenstatistieken leave
|
|
94
|
-
it out
|
|
95
|
-
counts none of its structuurvrijwilligers --
|
|
96
|
-
|
|
97
|
-
`
|
|
98
|
-
|
|
99
|
-
|
|
131
|
+
it out by default -- it is the national body, not an eenheid, and the client's own report normally
|
|
132
|
+
counts none of its structuurvrijwilligers -- but expose a boolean dashboard filter to include it.
|
|
133
|
+
The aanlevering is about nothing else.
|
|
134
|
+
`platform.membershipOrganizationId` is the only thing that says which organization that is, so the
|
|
135
|
+
same rows exist as two fragments: `includes/all-registrations.sql` with the koepel, and
|
|
136
|
+
`includes/all-non-platform-registrations.sql` -- those rows less the koepel unless the dashboard
|
|
137
|
+
filter includes it -- built on top of it.
|
|
138
|
+
The import writes the
|
|
139
|
+
koepel under that same id, so both hold in the years imported from the client's own statistics as
|
|
140
|
+
well as in the years the sync owns.
|
|
100
141
|
|
|
101
142
|
Installing Metabase differs per environment — Docker locally (`stam platform-report start`), a jar
|
|
102
143
|
under systemd on a server (`yarn metabase install` in devops) — but configuring it is the same HTTP
|
package/dist/api.d.ts
CHANGED
|
@@ -43,6 +43,18 @@ export type MetabaseCard = {
|
|
|
43
43
|
id: number;
|
|
44
44
|
name: string;
|
|
45
45
|
};
|
|
46
|
+
/** A shared query fragment, which questions refer to as `{{snippet: <name>}}`. */
|
|
47
|
+
export type MetabaseSnippet = {
|
|
48
|
+
id: number;
|
|
49
|
+
name: string;
|
|
50
|
+
content: string;
|
|
51
|
+
archived?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type MetabaseSnippetInput = {
|
|
54
|
+
name: string;
|
|
55
|
+
content: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
};
|
|
46
58
|
export type MetabaseDashboard = {
|
|
47
59
|
id: number;
|
|
48
60
|
name: string;
|
|
@@ -170,6 +182,22 @@ export declare class MetabaseApi {
|
|
|
170
182
|
* wrote under an earlier name along rather than leaving it beside a new one.
|
|
171
183
|
*/
|
|
172
184
|
renameCollection(id: number, name: string): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* The snippets of the instance, the archived ones included. A name is held by an archived snippet
|
|
187
|
+
* just as much as by a live one -- Metabase has no way to delete either -- so a fragment whose
|
|
188
|
+
* snippet was thrown away has to be found and revived rather than written a second time under a
|
|
189
|
+
* name that is already taken.
|
|
190
|
+
*/
|
|
191
|
+
listSnippets(): Promise<MetabaseSnippet[]>;
|
|
192
|
+
/**
|
|
193
|
+
* Write a shared fragment. Updating an existing one rather than replacing it keeps its id, and
|
|
194
|
+
* with it every question already pointing at it, so a fragment that changed reaches all of them
|
|
195
|
+
* at once. An archived one is brought back: its name was never given up.
|
|
196
|
+
*
|
|
197
|
+
* The description is written along, cleared when the fragment no longer has one: the sidebar
|
|
198
|
+
* would otherwise keep showing words the report stopped saying.
|
|
199
|
+
*/
|
|
200
|
+
saveSnippet(input: MetabaseSnippetInput, existingId?: number): Promise<number>;
|
|
173
201
|
listCards(collectionId: number): Promise<MetabaseCard[]>;
|
|
174
202
|
listDashboards(collectionId: number): Promise<MetabaseDashboard[]>;
|
|
175
203
|
/**
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CA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E,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS3G,0FAA0F;IACpF,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAYtE;;;;OAIG;IACG,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,EAAE,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzL;;;;;OAKG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAUlE,oCAAoC;IAC9B,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,2FAA2F;IACrF,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAInC,OAAO;CAmBxB"}
|
package/dist/api.js
CHANGED
|
@@ -217,6 +217,33 @@ export class MetabaseApi {
|
|
|
217
217
|
async renameCollection(id, name) {
|
|
218
218
|
await this.request('PUT', `/api/collection/${id}`, { name });
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* The snippets of the instance, the archived ones included. A name is held by an archived snippet
|
|
222
|
+
* just as much as by a live one -- Metabase has no way to delete either -- so a fragment whose
|
|
223
|
+
* snippet was thrown away has to be found and revived rather than written a second time under a
|
|
224
|
+
* name that is already taken.
|
|
225
|
+
*/
|
|
226
|
+
async listSnippets() {
|
|
227
|
+
const live = await this.request('GET', '/api/native-query-snippet');
|
|
228
|
+
const archived = await this.request('GET', '/api/native-query-snippet?archived=true');
|
|
229
|
+
return [...live, ...archived];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Write a shared fragment. Updating an existing one rather than replacing it keeps its id, and
|
|
233
|
+
* with it every question already pointing at it, so a fragment that changed reaches all of them
|
|
234
|
+
* at once. An archived one is brought back: its name was never given up.
|
|
235
|
+
*
|
|
236
|
+
* The description is written along, cleared when the fragment no longer has one: the sidebar
|
|
237
|
+
* would otherwise keep showing words the report stopped saying.
|
|
238
|
+
*/
|
|
239
|
+
async saveSnippet(input, existingId) {
|
|
240
|
+
const body = { name: input.name, content: input.content, description: input.description ?? null };
|
|
241
|
+
if (existingId !== undefined) {
|
|
242
|
+
await this.request('PUT', `/api/native-query-snippet/${existingId}`, { ...body, archived: false });
|
|
243
|
+
return existingId;
|
|
244
|
+
}
|
|
245
|
+
return (await this.request('POST', '/api/native-query-snippet', body)).id;
|
|
246
|
+
}
|
|
220
247
|
async listCards(collectionId) {
|
|
221
248
|
const items = await this.request('GET', `/api/collection/${collectionId}/items?models=card`);
|
|
222
249
|
return (items.data ?? []).map(item => ({ id: item.id, name: item.name }));
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AA+DA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACD;IAAtC,YAAY,OAAe,EAAW,MAAc;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,WAAM,GAAN,MAAM,CAAQ;QAEhD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACnC,CAAC;CACJ;AAQD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,WAAW;IAIS;IAHrB,OAAO,CAAqB;IACnB,MAAM,CAAqB;IAE5C,YAA6B,OAAe,EAAE,UAA+B,EAAE;QAAlD,YAAO,GAAP,OAAO,CAAQ;QACxC,IAAI,CAAC,MAAM,GAAG,OAAO,CA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,MAAM,IAAI,IAAI,uBAAuB,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClI,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAM,CAAC;IACnE,CAAC;CACJ"}
|
package/dist/report.d.ts
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
* -- @card totaal-leden
|
|
14
14
|
* -- title: Totaal leden
|
|
15
15
|
* -- display: scalar
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* WITH leden AS (
|
|
17
|
+
* -- @include deduplicated-non-platform-registrations
|
|
18
|
+
* )
|
|
19
|
+
* SELECT COUNT(DISTINCT member_id) AS `Totaal leden` FROM leden
|
|
18
20
|
*
|
|
19
21
|
* `@include <name>` is replaced by `includes/<name>.sql`, which is how every card counts members the
|
|
20
22
|
* same way, and a fragment may include another. `{{name}}` marks a query parameter, the same syntax
|
|
@@ -22,6 +24,12 @@
|
|
|
22
24
|
* several values can be chosen for is written `IN ({{name}})`, since Metabase replaces it with all of
|
|
23
25
|
* them, comma separated.
|
|
24
26
|
*
|
|
27
|
+
* A card is read twice over. `sql` is the query with every fragment expanded, which is the whole of
|
|
28
|
+
* what it counts and what the tests check. `snippetSql` leaves the fragments where they stand, as the
|
|
29
|
+
* `{{snippet: ...}}` references Metabase understands, and is what Metabase is given: a fragment is
|
|
30
|
+
* written there as a snippet of its own, so what a lid is stands in one place and an edit to it
|
|
31
|
+
* reaches every question that reads it.
|
|
32
|
+
*
|
|
25
33
|
* The same report is written for every platform, which do not all count the same thing the same way.
|
|
26
34
|
* Where they differ, the environment says which variant a card gets: `includes/<env>/<name>.sql`
|
|
27
35
|
* replaces the fragment of that name, and a setting written `-- description@<env>:` replaces the
|
|
@@ -79,12 +87,32 @@ export type ReportCard = {
|
|
|
79
87
|
best: ReportCardBest;
|
|
80
88
|
/**
|
|
81
89
|
* How the labels along the x-axis are drawn. Absent lets the chart decide, which drops them
|
|
82
|
-
* entirely when too many do not fit -- an eenheid or
|
|
90
|
+
* entirely when too many do not fit -- an eenheid or leeftijdsgroep chart needs a rotation to keep them.
|
|
83
91
|
*/
|
|
84
92
|
xLabels?: ReportCardXLabels;
|
|
85
93
|
/** Parameters the query takes, read from the `{{...}}` in the sql. */
|
|
86
94
|
parameters: string[];
|
|
95
|
+
/**
|
|
96
|
+
* The fragments this card reads, the ones those fragments read included. Metabase resolves a
|
|
97
|
+
* snippet against the tags of the question it stands in and not against the snippet that refers
|
|
98
|
+
* to it, so a card has to name the fragments it only reaches through another one as well.
|
|
99
|
+
*/
|
|
100
|
+
snippets: string[];
|
|
87
101
|
sql: string;
|
|
102
|
+
/** The same query with the fragments left as references, which is the form Metabase is given. */
|
|
103
|
+
snippetSql: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* A shared fragment as Metabase holds it: one snippet, referred to by every question that reads it.
|
|
107
|
+
*
|
|
108
|
+
* The fragments it includes itself stay references, so a fragment holds `{{snippet: all-registrations}}`
|
|
109
|
+
* rather than a second copy of those rows -- the same nesting the `.sql` files are written in.
|
|
110
|
+
*/
|
|
111
|
+
export type ReportSnippet = {
|
|
112
|
+
name: string;
|
|
113
|
+
sql: string;
|
|
114
|
+
/** What the snippet sidebar lists the fragment under: a `-- description:` first line in its file. */
|
|
115
|
+
description?: string;
|
|
88
116
|
};
|
|
89
117
|
export type ReportTab = {
|
|
90
118
|
key: string;
|
|
@@ -104,6 +132,16 @@ export type ReportTab = {
|
|
|
104
132
|
* any tab is visible everywhere; this is what decides which cards it actually reaches.
|
|
105
133
|
*/
|
|
106
134
|
filters: string[];
|
|
135
|
+
/**
|
|
136
|
+
* The filters of this tab that have to be answered before its cards say anything. Metabase marks
|
|
137
|
+
* such a filter on the dashboard and refuses to run a card that has no value for it, which is
|
|
138
|
+
* what a tab whose cards are wrong rather than broad without one asks for: the aanlevering
|
|
139
|
+
* delivers one werkjaar, and every werkjaar at once is not a delivery anyone can file.
|
|
140
|
+
*
|
|
141
|
+
* Named per tab rather than with the filter, since the same filter is read both ways: the
|
|
142
|
+
* ledenstatistieken count every werkjaar until a reader picks one.
|
|
143
|
+
*/
|
|
144
|
+
required: string[];
|
|
107
145
|
/** Cards that only feed the filter dropdowns. They live in the collection but on no tab. */
|
|
108
146
|
hidden: boolean;
|
|
109
147
|
cards: ReportCard[];
|
|
@@ -120,11 +158,20 @@ export declare function getReportDirectory(): string;
|
|
|
120
158
|
/**
|
|
121
159
|
* The report as one environment counts it.
|
|
122
160
|
*
|
|
123
|
-
* Not every figure is counted the same everywhere -- the GTP index weighs
|
|
161
|
+
* Not every figure is counted the same everywhere -- the GTP index weighs leeftijdsgroepen for keeo and ages
|
|
124
162
|
* for ravot -- and a statistics database holds one platform, so which variant a card gets is decided
|
|
125
163
|
* here rather than in the queries. `env` is the same name the data source carries.
|
|
126
164
|
*/
|
|
127
165
|
export declare function loadReport(env: string, directory?: string): Promise<ReportTab[]>;
|
|
166
|
+
/**
|
|
167
|
+
* The shared fragments of an environment, each one as the snippet Metabase holds it in.
|
|
168
|
+
*
|
|
169
|
+
* Written beside the questions so the definitions live in one place there as well: a question refers
|
|
170
|
+
* to `{{snippet: deduplicated-non-platform-registrations}}`, and whoever changes what a lid is changes it once instead of in every
|
|
171
|
+
* card that counts one. Which variant a fragment has is settled here, the same way it is for a card,
|
|
172
|
+
* so a snippet carries what this platform counts without saying which platform that is.
|
|
173
|
+
*/
|
|
174
|
+
export declare function loadSnippets(env: string, directory?: string): Promise<ReportSnippet[]>;
|
|
128
175
|
/**
|
|
129
176
|
* Splits a file into its `@tab` header and `@card` sections. Everything that is not a directive
|
|
130
177
|
* stays as it is, so a card's sql keeps the comments written above it.
|
package/dist/report.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,MAAM,UAAU,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,IAAI,EAAE,cAAc,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;OAIG;IACH,IAAI,EAAE,cAAc,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,sEAAsE;IACtE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,MAAM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E,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CA6C/G;AAiOD,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpD;AAcD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM,GAAG,MAAM,CAS1F"}
|
package/dist/report.js
CHANGED
|
@@ -12,37 +12,46 @@ export function getReportDirectory() {
|
|
|
12
12
|
/**
|
|
13
13
|
* The report as one environment counts it.
|
|
14
14
|
*
|
|
15
|
-
* Not every figure is counted the same everywhere -- the GTP index weighs
|
|
15
|
+
* Not every figure is counted the same everywhere -- the GTP index weighs leeftijdsgroepen for keeo and ages
|
|
16
16
|
* for ravot -- and a statistics database holds one platform, so which variant a card gets is decided
|
|
17
17
|
* here rather than in the queries. `env` is the same name the data source carries.
|
|
18
18
|
*/
|
|
19
19
|
export async function loadReport(env, directory = getReportDirectory()) {
|
|
20
20
|
const includes = await loadIncludes(path.join(directory, 'includes'), env);
|
|
21
|
+
const sql = new Map([...includes].map(([name, include]) => [name, include.sql]));
|
|
21
22
|
const files = (await fs.readdir(directory)).filter(file => file.endsWith('.sql')).sort();
|
|
22
23
|
const tabs = await Promise.all(files.map(async (file) => {
|
|
23
|
-
return parseTab(await fs.readFile(path.join(directory, file), 'utf-8'), file,
|
|
24
|
+
return parseTab(await fs.readFile(path.join(directory, file), 'utf-8'), file, sql, env);
|
|
24
25
|
}));
|
|
25
26
|
return tabs.sort((a, b) => orderOf(a.key) - orderOf(b.key));
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The shared fragments of an environment, each one as the snippet Metabase holds it in.
|
|
30
|
+
*
|
|
31
|
+
* Written beside the questions so the definitions live in one place there as well: a question refers
|
|
32
|
+
* to `{{snippet: deduplicated-non-platform-registrations}}`, and whoever changes what a lid is changes it once instead of in every
|
|
33
|
+
* card that counts one. Which variant a fragment has is settled here, the same way it is for a card,
|
|
34
|
+
* so a snippet carries what this platform counts without saying which platform that is.
|
|
35
|
+
*/
|
|
36
|
+
export async function loadSnippets(env, directory = getReportDirectory()) {
|
|
37
|
+
const includes = await loadIncludes(path.join(directory, 'includes'), env);
|
|
38
|
+
return [...includes]
|
|
39
|
+
.map(([name, include]) => ({ name, sql: referenceIncludes(include.sql), description: include.description }))
|
|
40
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
41
|
+
}
|
|
27
42
|
function orderOf(key) {
|
|
28
43
|
const index = reportTabOrder.indexOf(key);
|
|
29
44
|
return index === -1 ? reportTabOrder.length : index;
|
|
30
45
|
}
|
|
31
|
-
/**
|
|
32
|
-
* The shared fragments, with the ones this environment counts differently laid over them:
|
|
33
|
-
* `includes/<env>/gtp.sql` is what `@include gtp` expands to there, while every other environment
|
|
34
|
-
* keeps `includes/gtp.sql`. A card therefore never says which platform it is written for.
|
|
35
|
-
*
|
|
36
|
-
* An override of a name no fragment carries is a mistake rather than a fragment only one environment
|
|
37
|
-
* has: nothing includes it, so a misspelled file would change nothing and say nothing.
|
|
38
|
-
*/
|
|
39
46
|
async function loadIncludes(directory, env) {
|
|
40
47
|
const includes = await readIncludes(directory);
|
|
41
|
-
for (const [name,
|
|
42
|
-
|
|
48
|
+
for (const [name, include] of await readIncludes(path.join(directory, env))) {
|
|
49
|
+
const base = includes.get(name);
|
|
50
|
+
if (base === undefined) {
|
|
43
51
|
throw new Error(`includes/${env}/${name}.sql overrides "${name}", which has no includes/${name}.sql`);
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
// A variant that says nothing about itself keeps the words of the fragment it replaces.
|
|
54
|
+
includes.set(name, { sql: include.sql, description: include.description ?? base.description });
|
|
46
55
|
}
|
|
47
56
|
return includes;
|
|
48
57
|
}
|
|
@@ -60,10 +69,24 @@ async function readIncludes(directory) {
|
|
|
60
69
|
}
|
|
61
70
|
const includes = new Map();
|
|
62
71
|
for (const file of entries.filter(entry => entry.endsWith('.sql'))) {
|
|
63
|
-
includes.set(path.basename(file, '.sql'), (await fs.readFile(path.join(directory, file), 'utf-8')).trim());
|
|
72
|
+
includes.set(path.basename(file, '.sql'), parseInclude((await fs.readFile(path.join(directory, file), 'utf-8')).trim()));
|
|
64
73
|
}
|
|
65
74
|
return includes;
|
|
66
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A fragment may open on a `-- description:` line, which becomes the snippet's description in
|
|
78
|
+
* Metabase rather than a comment in its sql -- the sidebar shows it next to the name, where a
|
|
79
|
+
* comment would only be read after opening the fragment.
|
|
80
|
+
*/
|
|
81
|
+
function parseInclude(contents) {
|
|
82
|
+
// The value keeps its leading spaces here and is trimmed below: two adjacent quantifiers could
|
|
83
|
+
// split one run of spaces many ways.
|
|
84
|
+
const description = /^--[ \t]*description:(.*)\r?\n/.exec(contents);
|
|
85
|
+
if (!description) {
|
|
86
|
+
return { sql: contents };
|
|
87
|
+
}
|
|
88
|
+
return { description: description[1].trim(), sql: contents.slice(description[0].length).trim() };
|
|
89
|
+
}
|
|
67
90
|
/**
|
|
68
91
|
* Splits a file into its `@tab` header and `@card` sections. Everything that is not a directive
|
|
69
92
|
* stays as it is, so a card's sql keeps the comments written above it.
|
|
@@ -90,12 +113,20 @@ export function parseTab(contents, file, includes, env) {
|
|
|
90
113
|
if (unused.length > 0) {
|
|
91
114
|
throw new Error(`${file}: filter "${unused[0]}" is declared but no card uses {{${unused[0]}}}`);
|
|
92
115
|
}
|
|
116
|
+
// A filter the dashboard does not show is one nobody can answer, so requiring it would leave
|
|
117
|
+
// every card of the tab refusing to run with nothing on screen to say why.
|
|
118
|
+
const requiredFilters = splitList(header.attributes.get('required'));
|
|
119
|
+
const unshown = requiredFilters.filter(filter => !filters.includes(filter));
|
|
120
|
+
if (unshown.length > 0) {
|
|
121
|
+
throw new Error(`${file}: filter "${unshown[0]}" is required but not among the filters of the tab`);
|
|
122
|
+
}
|
|
93
123
|
return {
|
|
94
124
|
key: header.key,
|
|
95
125
|
title: required(header.attributes, 'title', file, header.key),
|
|
96
126
|
description: header.attributes.get('description'),
|
|
97
127
|
dashboard: header.attributes.get('dashboard'),
|
|
98
128
|
filters,
|
|
129
|
+
required: requiredFilters,
|
|
99
130
|
hidden: header.attributes.get('hidden') === 'true',
|
|
100
131
|
cards,
|
|
101
132
|
};
|
|
@@ -105,7 +136,7 @@ export function parseTab(contents, file, includes, env) {
|
|
|
105
136
|
* slipped down rather than a comment, and would otherwise be dropped without a word: writing a
|
|
106
137
|
* comment above `-- size:` is enough to make the whole block below it stop counting.
|
|
107
138
|
*/
|
|
108
|
-
const knownAttributes = new Set(['title', 'display', 'size', 'description', 'dimensions', 'metrics', 'columns', 'stacked', 'segments', 'best', 'xlabels', 'height', 'span', 'latitude', 'longitude', 'filters', 'hidden', 'dashboard']);
|
|
139
|
+
const knownAttributes = new Set(['title', 'display', 'size', 'description', 'dimensions', 'metrics', 'columns', 'stacked', 'segments', 'best', 'xlabels', 'height', 'span', 'latitude', 'longitude', 'filters', 'required', 'hidden', 'dashboard']);
|
|
109
140
|
function splitSections(contents, file, env) {
|
|
110
141
|
const sections = [];
|
|
111
142
|
let current;
|
|
@@ -200,7 +231,9 @@ function parseCard(section, file, includes) {
|
|
|
200
231
|
best,
|
|
201
232
|
xLabels: xLabels,
|
|
202
233
|
parameters: parameterNames(sql),
|
|
234
|
+
snippets: collectIncludes(section.body, includes),
|
|
203
235
|
sql,
|
|
236
|
+
snippetSql: referenceIncludes(section.body).trim(),
|
|
204
237
|
};
|
|
205
238
|
}
|
|
206
239
|
/** A setting counted in whole cards or rows, which is only a size while it is a positive number. */
|
|
@@ -252,9 +285,11 @@ function parseRanges(section, file, display) {
|
|
|
252
285
|
}
|
|
253
286
|
return { segments, best: best };
|
|
254
287
|
}
|
|
255
|
-
/**
|
|
288
|
+
/** The line a fragment is asked for on, which is either expanded or turned into a reference. */
|
|
289
|
+
const includeDirective = /^([ \t]*)--[ \t]*@include[ \t]+(\S+)[ \t]*$/gm;
|
|
290
|
+
/** A fragment may include another, which is how the two registration grains share their filters. */
|
|
256
291
|
function expandIncludes(body, includes, file, card, chain = []) {
|
|
257
|
-
return body.replaceAll(
|
|
292
|
+
return body.replaceAll(includeDirective, (_match, indent, name) => {
|
|
258
293
|
const include = includes.get(name);
|
|
259
294
|
if (include === undefined) {
|
|
260
295
|
throw new Error(`${file}: card "${card}" includes "${name}", which has no report/includes/${name}.sql`);
|
|
@@ -266,6 +301,29 @@ function expandIncludes(body, includes, file, card, chain = []) {
|
|
|
266
301
|
.split('\n').map(line => indent + line).join('\n');
|
|
267
302
|
});
|
|
268
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* The same body with each fragment left where it stands, as the reference Metabase resolves against
|
|
306
|
+
* its snippets. Nothing is checked here: `expandIncludes` has already refused a fragment that is not
|
|
307
|
+
* there and one that includes itself.
|
|
308
|
+
*/
|
|
309
|
+
function referenceIncludes(body) {
|
|
310
|
+
return body.replaceAll(includeDirective, (_match, indent, name) => `${indent}{{snippet: ${name}}}`);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Every fragment a body reads, in the order it reaches them, the ones its fragments read included.
|
|
314
|
+
* A question has to name those too: Metabase looks a nested `{{snippet: all-registrations}}` up among the tags
|
|
315
|
+
* of the question rather than among those of the fragment that refers to it.
|
|
316
|
+
*/
|
|
317
|
+
function collectIncludes(body, includes, found = []) {
|
|
318
|
+
for (const [, , name] of body.matchAll(includeDirective)) {
|
|
319
|
+
if (found.includes(name)) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
found.push(name);
|
|
323
|
+
collectIncludes(includes.get(name) ?? '', includes, found);
|
|
324
|
+
}
|
|
325
|
+
return found;
|
|
326
|
+
}
|
|
269
327
|
/** The `{{name}}` parameters a query uses, in the order they first appear. */
|
|
270
328
|
export function parameterNames(sql) {
|
|
271
329
|
return [...new Set([...sql.matchAll(/\{\{\s*([a-z_]+)\s*\}\}/g)].map(match => match[1]))];
|