@stamhoofd/metabase 2.152.0 → 2.160.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/LICENSE.md +7 -7
- package/README.md +113 -33
- package/dist/api.js +32 -17
- package/dist/api.js.map +1 -1
- package/dist/report.js +197 -44
- package/dist/report.js.map +1 -1
- package/dist/sync-report.js +181 -49
- package/dist/sync-report.js.map +1 -1
- package/dist-types/api.d.ts.map +1 -0
- package/{dist → dist-types}/report.d.ts +70 -15
- package/dist-types/report.d.ts.map +1 -0
- package/{dist → dist-types}/sync-report.d.ts +5 -1
- package/dist-types/sync-report.d.ts.map +1 -0
- package/package.json +40 -32
- package/report/eenheden.sql +31 -0
- package/report/gtp.sql +80 -0
- package/report/includes/all-non-platform-registrations-all-years.sql +19 -1
- package/report/includes/all-registrations.sql +8 -1
- package/report/includes/deduplicated-non-platform-registrations-all-years.sql +1 -0
- package/report/includes/deduplicated-non-platform-registrations.sql +2 -1
- package/report/includes/filter-registration-types.sql +20 -2
- package/report/includes/keeo/participant-counts.sql +4 -0
- package/report/includes/keeo/participant-detail-columns.sql +2 -0
- package/report/includes/keeo/participant-details.sql +2 -0
- package/report/includes/keeo/participant-subgroup.sql +6 -0
- package/report/includes/keeo/participant-type.sql +8 -0
- package/report/includes/participant-counts.sql +2 -0
- package/report/includes/participant-detail-columns.sql +2 -0
- package/report/includes/participant-details.sql +3 -0
- package/report/includes/participant-subgroup.sql +2 -0
- package/report/includes/uldk-zonder-geslacht.sql +11 -0
- package/report/jeugdbewegingen.sql +93 -22
- package/report/nationaal.sql +2 -0
- package/report/varia.sql +31 -0
- package/dist/api.d.ts.map +0 -1
- package/dist/report.d.ts.map +0 -1
- package/dist/sync-report.d.ts.map +0 -1
- /package/{dist → dist-types}/api.d.ts +0 -0
- /package/{dist → dist-types}/naming.d.ts +0 -0
- /package/{dist → dist-types}/naming.d.ts.map +0 -0
|
@@ -19,21 +19,28 @@
|
|
|
19
19
|
* SELECT COUNT(DISTINCT member_id) AS `Totaal leden` FROM leden
|
|
20
20
|
*
|
|
21
21
|
* `@include <name>` is replaced by `includes/<name>.sql`, which is how every card counts members the
|
|
22
|
-
* same way, and a fragment may include another.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* same way, and a fragment may include another. `@inline <name>` reads the same file and writes it
|
|
23
|
+
* out where it stands instead of referring to it, for a fragment that only exists so an environment
|
|
24
|
+
* can say a piece of a query its own way and is not a definition anyone would open on its own.
|
|
25
|
+
* `{{name}}` marks a query parameter, the same syntax Metabase uses, and `[[...]]` around a clause
|
|
26
|
+
* drops it when that parameter is empty. A parameter several values can be chosen for is written
|
|
27
|
+
* `IN ({{name}})`, since Metabase replaces it with all of them, comma separated.
|
|
26
28
|
*
|
|
27
29
|
* 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
|
|
29
|
-
* `{{snippet: ...}}` references Metabase understands, and is what Metabase is given: a
|
|
30
|
-
* written there as a snippet of its own, so what a lid is stands in one place and an edit
|
|
31
|
-
* reaches every question that reads it.
|
|
30
|
+
* what it counts and what the tests check. `snippetSql` leaves the included fragments where they
|
|
31
|
+
* stand, as the `{{snippet: ...}}` references Metabase understands, and is what Metabase is given: a
|
|
32
|
+
* fragment is written there as a snippet of its own, so what a lid is stands in one place and an edit
|
|
33
|
+
* to it reaches every question that reads it. An inlined one is expanded in both.
|
|
32
34
|
*
|
|
33
35
|
* The same report is written for every platform, which do not all count the same thing the same way.
|
|
34
36
|
* Where they differ, the environment says which variant a card gets: `includes/<env>/<name>.sql`
|
|
35
37
|
* replaces the fragment of that name, and a setting written `-- description@<env>:` replaces the
|
|
36
38
|
* unqualified one. Neither is visible to a card, which keeps saying `@include gtp`.
|
|
39
|
+
*
|
|
40
|
+
* A figure a platform does not record at all is the one thing no variant can say: `-- except: keeo`
|
|
41
|
+
* on a tab or a card leaves it out there, and the report is written without it. `-- only: keeo` is
|
|
42
|
+
* the other way round and is what a figure drawn two ways needs -- a card cannot be two shapes, so
|
|
43
|
+
* the second is a card of its own, written where the first is not and nowhere else.
|
|
37
44
|
*/
|
|
38
45
|
export type ReportCard = {
|
|
39
46
|
key: string;
|
|
@@ -60,7 +67,7 @@ export type ReportCard = {
|
|
|
60
67
|
description?: string;
|
|
61
68
|
/** Columns to group by, for the chart displays. */
|
|
62
69
|
dimensions: string[];
|
|
63
|
-
/** Columns to plot, for the chart displays. */
|
|
70
|
+
/** Columns to plot, for the chart displays. For a table, the columns its segments color. */
|
|
64
71
|
metrics: string[];
|
|
65
72
|
/**
|
|
66
73
|
* The headers a table has to be exported under, in order. Named here because a card that is
|
|
@@ -74,7 +81,8 @@ export type ReportCard = {
|
|
|
74
81
|
/**
|
|
75
82
|
* The boundaries the figure is read in, lowest first: `0, 35, 55, 75, 95, 115, 135` makes six
|
|
76
83
|
* ranges. A gauge draws them as its arc and a number is colored by the one it falls in, which is
|
|
77
|
-
* how the two cards of one figure say the same thing.
|
|
84
|
+
* how the two cards of one figure say the same thing. A table colors the cells of its metrics the
|
|
85
|
+
* same way. The outer two are where the arc starts and
|
|
78
86
|
* stops rather than a figure anything is measured against, since the figure itself has no ends.
|
|
79
87
|
* Absent leaves a gauge to Metabase, which splits the arc in three, and a number uncolored.
|
|
80
88
|
*/
|
|
@@ -85,13 +93,44 @@ export type ReportCard = {
|
|
|
85
93
|
* the fewer leden a leider has to look after, the better.
|
|
86
94
|
*/
|
|
87
95
|
best: ReportCardBest;
|
|
96
|
+
/**
|
|
97
|
+
* For a table, the column whose value colors the whole row, in the colors `columnPalettes` gives
|
|
98
|
+
* that column's values. The column itself is hidden: the row color says what it holds. A cell
|
|
99
|
+
* colored by the segments keeps its own color.
|
|
100
|
+
*/
|
|
101
|
+
highlight?: string;
|
|
88
102
|
/**
|
|
89
103
|
* How the labels along the x-axis are drawn. Absent lets the chart decide, which drops them
|
|
90
104
|
* entirely when too many do not fit -- an eenheid or leeftijdsgroep chart needs a rotation to keep them.
|
|
91
105
|
*/
|
|
92
106
|
xLabels?: ReportCardXLabels;
|
|
107
|
+
/**
|
|
108
|
+
* How the x-axis reads the values it is given. Absent leaves it to Metabase, which reads a column
|
|
109
|
+
* of numbers as a `linear` axis and ticks it at round numbers -- a leeftijdenchart labelled 10,
|
|
110
|
+
* 20, 30 rather than per bar. `ordinal` makes every value a category of its own, which is what a
|
|
111
|
+
* chart with a bar per value wants, and what a column of text already gets.
|
|
112
|
+
*/
|
|
113
|
+
xScale?: ReportCardXScale;
|
|
93
114
|
/** Parameters the query takes, read from the `{{...}}` in the sql. */
|
|
94
115
|
parameters: string[];
|
|
116
|
+
/**
|
|
117
|
+
* Numbers a parameter takes when no filter gives it one, written `-- defaults: aantal_werkjaren = 3`.
|
|
118
|
+
* It is how a card switches on an optional clause of a fragment that no dashboard filter drives.
|
|
119
|
+
* Internal parameter lookup; Metabase JSON tags are constructed separately by sync-report.
|
|
120
|
+
*/
|
|
121
|
+
defaults: Map<string, number>;
|
|
122
|
+
/**
|
|
123
|
+
* The environments this card is not written for. A platform that does not record what the card
|
|
124
|
+
* counts has no variant of it to be given, only an empty one, so it is left out there instead.
|
|
125
|
+
*/
|
|
126
|
+
except: string[];
|
|
127
|
+
/**
|
|
128
|
+
* The environments this card is written for, and no others. Empty is every one of them, which is
|
|
129
|
+
* what nearly every card is. It is the second shape of a figure that says one: the card it stands
|
|
130
|
+
* in for leaves out the same environments this names, so exactly one of the two is ever written
|
|
131
|
+
* -- where `except` alone would give a platform that named neither both of them.
|
|
132
|
+
*/
|
|
133
|
+
only: string[];
|
|
95
134
|
/**
|
|
96
135
|
* The fragments this card reads, the ones those fragments read included. Metabase resolves a
|
|
97
136
|
* snippet against the tags of the question it stands in and not against the snippet that refers
|
|
@@ -99,7 +138,7 @@ export type ReportCard = {
|
|
|
99
138
|
*/
|
|
100
139
|
snippets: string[];
|
|
101
140
|
sql: string;
|
|
102
|
-
/** The same query with the fragments left as references, which is
|
|
141
|
+
/** The same query with the included fragments left as references, which is what Metabase is given. */
|
|
103
142
|
snippetSql: string;
|
|
104
143
|
};
|
|
105
144
|
/**
|
|
@@ -144,14 +183,21 @@ export type ReportTab = {
|
|
|
144
183
|
required: string[];
|
|
145
184
|
/** Cards that only feed the filter dropdowns. They live in the collection but on no tab. */
|
|
146
185
|
hidden: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* The environments this tab is not written for, which is where every card of it is left out:
|
|
188
|
+
* a tab whose cards are all about a figure the platform does not record has nothing to show.
|
|
189
|
+
*/
|
|
190
|
+
except: string[];
|
|
147
191
|
cards: ReportCard[];
|
|
148
192
|
};
|
|
149
193
|
export declare const reportCardSizes: readonly ["full", "two-thirds", "half", "third", "quarter", "sixth"];
|
|
150
|
-
export type ReportCardSize = typeof reportCardSizes[number];
|
|
194
|
+
export type ReportCardSize = (typeof reportCardSizes)[number];
|
|
151
195
|
export declare const reportCardXLabels: readonly ["show", "hide", "compact", "rotate-45", "rotate-90"];
|
|
152
|
-
export type ReportCardXLabels = typeof reportCardXLabels[number];
|
|
196
|
+
export type ReportCardXLabels = (typeof reportCardXLabels)[number];
|
|
197
|
+
export declare const reportCardXScales: readonly ["ordinal", "linear"];
|
|
198
|
+
export type ReportCardXScale = (typeof reportCardXScales)[number];
|
|
153
199
|
export declare const reportCardBest: readonly ["low", "high"];
|
|
154
|
-
export type ReportCardBest = typeof reportCardBest[number];
|
|
200
|
+
export type ReportCardBest = (typeof reportCardBest)[number];
|
|
155
201
|
/** The order the tabs are written in: the pages of the client's report first, then what is not one. */
|
|
156
202
|
export declare const reportTabOrder: string[];
|
|
157
203
|
export declare function getReportDirectory(): string;
|
|
@@ -163,6 +209,14 @@ export declare function getReportDirectory(): string;
|
|
|
163
209
|
* here rather than in the queries. `env` is the same name the data source carries.
|
|
164
210
|
*/
|
|
165
211
|
export declare function loadReport(env: string, directory?: string): Promise<ReportTab[]>;
|
|
212
|
+
/**
|
|
213
|
+
* What this environment leaves out, as the tabs holding it: a tab it does not write, with every card
|
|
214
|
+
* of it, and a tab it does write, with only the cards it leaves out.
|
|
215
|
+
*
|
|
216
|
+
* A question is stored under its card and its tab both, so clearing away one an earlier run wrote
|
|
217
|
+
* needs the two of them -- and the report this environment loads no longer holds either.
|
|
218
|
+
*/
|
|
219
|
+
export declare function loadRetiredReport(env: string, directory?: string): Promise<ReportTab[]>;
|
|
166
220
|
/**
|
|
167
221
|
* The shared fragments of an environment, each one as the snippet Metabase holds it in.
|
|
168
222
|
*
|
|
@@ -183,6 +237,7 @@ export declare function parameterNames(sql: string): string[];
|
|
|
183
237
|
* The sql as it runs outside Metabase: parameters resolved and the `[[...]]` clauses around them
|
|
184
238
|
* kept or dropped. Used by the tests to run a card against a real database, since Metabase is the
|
|
185
239
|
* only thing that understands this syntax.
|
|
240
|
+
* Values are literal parameter names; null and missing values drop optional clauses.
|
|
186
241
|
*/
|
|
187
|
-
export declare function resolveSql(sql: string, values?:
|
|
242
|
+
export declare function resolveSql(sql: string, values?: ReadonlyMap<string, string | null>): string;
|
|
188
243
|
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;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,MA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B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,GAAG,CAAC,EAAE,MAAM,GACb,SAAS,CA0DX;AAsYD,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpD;AAwBD;;;;;GAKG;AACH,wBAAgB,UAAU,CACtB,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAa,GACvD,MAAM,CAaR"}
|
|
@@ -230,8 +230,12 @@ export declare function syncSnippets(api: MetabaseApi, snippets: readonly Report
|
|
|
230
230
|
*
|
|
231
231
|
* `env` is the platform being written, the same name the report was loaded for. It says which colors
|
|
232
232
|
* a chart falls back to; without it they are Metabase's.
|
|
233
|
+
*
|
|
234
|
+
* `retired` is what that environment leaves out. Nothing is written for it -- it is there so the
|
|
235
|
+
* questions an earlier run wrote can be told apart from the ones the client wrote themselves, and
|
|
236
|
+
* cleared away rather than left standing beside the report they are no longer part of.
|
|
233
237
|
*/
|
|
234
|
-
export declare function syncReport(api: MetabaseApi, databaseId: number, tabs: ReportTab[], snippets: readonly ReportSnippet[], collection: string, dashboardName: string, hasCoordinates?: boolean, env?: string): Promise<ReportSyncResult>;
|
|
238
|
+
export declare function syncReport(api: MetabaseApi, databaseId: number, tabs: ReportTab[], snippets: readonly ReportSnippet[], collection: string, dashboardName: string, hasCoordinates?: boolean, env?: string, retired?: ReportTab[]): Promise<ReportSyncResult>;
|
|
235
239
|
/**
|
|
236
240
|
* The collection to rename into the one written now: the one this wrote while collections were named
|
|
237
241
|
* per environment. Renaming keeps its id, and with it every question, dashboard, link and bookmark
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-report.d.ts","sourceRoot":"","sources":["../src/sync-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;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-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@stamhoofd/metabase",
|
|
3
|
+
"version": "2.160.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/stamhoofd/stamhoofd.git",
|
|
7
|
+
"directory": "shared/metabase"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
"./*": {
|
|
13
|
+
"types": "./dist-types/*.d.ts",
|
|
14
|
+
"import": "./dist/*.js",
|
|
15
|
+
"require": "./dist/*.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"dist-types",
|
|
21
|
+
"report"
|
|
22
|
+
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"oxlint-plugin-stamhoofd": "2.160.0",
|
|
25
|
+
"@stamhoofd/test-utils": "2.160.0",
|
|
26
|
+
"@stamhoofd/types": "2.160.0",
|
|
27
|
+
"vitest": "4.1.12"
|
|
28
|
+
},
|
|
29
|
+
"license": "UNLICENCED",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc --build tsconfig.build.json",
|
|
35
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
36
|
+
"lint": "oxlint . --quiet --type-aware --threads 2",
|
|
37
|
+
"typecheck": "tsc --project tsconfig.test.json --noEmit --composite false --incremental --tsBuildInfoFile .cache/typecheck.tsbuildinfo",
|
|
38
|
+
"test": "vitest",
|
|
39
|
+
"test:coverage": "vitest --coverage"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/report/eenheden.sql
CHANGED
|
@@ -181,6 +181,7 @@ ORDER BY MIN(period_start)
|
|
|
181
181
|
|
|
182
182
|
-- @card eenheid-leden-per-geslacht
|
|
183
183
|
-- title: Aantal leden per geslacht
|
|
184
|
+
-- except: keeo
|
|
184
185
|
-- display: pie
|
|
185
186
|
-- size: half
|
|
186
187
|
-- dimensions: Geslacht
|
|
@@ -197,6 +198,7 @@ ORDER BY `Aantal leden` DESC
|
|
|
197
198
|
-- title: Aantal leden per type lidgeld
|
|
198
199
|
-- display: pie
|
|
199
200
|
-- size: half
|
|
201
|
+
-- size@keeo: full
|
|
200
202
|
-- dimensions: Type lidgeld
|
|
201
203
|
-- metrics: Aantal leden
|
|
202
204
|
WITH leden AS (
|
|
@@ -262,6 +264,7 @@ ORDER BY MIN(period_start) DESC
|
|
|
262
264
|
|
|
263
265
|
-- @card eenheid-geslacht-kinderen-per-jaar
|
|
264
266
|
-- title: Verhouding tussen de geslachten: kinderen
|
|
267
|
+
-- except: keeo
|
|
265
268
|
-- display: row
|
|
266
269
|
-- size: two-thirds
|
|
267
270
|
-- dimensions: Werkjaar, Geslacht
|
|
@@ -282,6 +285,7 @@ ORDER BY MIN(period_start) DESC
|
|
|
282
285
|
|
|
283
286
|
-- @card eenheid-kinderen-per-geslacht
|
|
284
287
|
-- title: Aantal kinderen per geslacht
|
|
288
|
+
-- except: keeo
|
|
285
289
|
-- display: pie
|
|
286
290
|
-- size: third
|
|
287
291
|
-- dimensions: Geslacht
|
|
@@ -297,6 +301,7 @@ ORDER BY `Aantal kinderen` DESC
|
|
|
297
301
|
|
|
298
302
|
-- @card eenheid-geslacht-leiding-per-jaar
|
|
299
303
|
-- title: Verhouding tussen de geslachten: leiding
|
|
304
|
+
-- except: keeo
|
|
300
305
|
-- display: row
|
|
301
306
|
-- size: two-thirds
|
|
302
307
|
-- dimensions: Werkjaar, Geslacht
|
|
@@ -317,6 +322,7 @@ ORDER BY MIN(period_start) DESC
|
|
|
317
322
|
|
|
318
323
|
-- @card eenheid-leiding-per-geslacht
|
|
319
324
|
-- title: Aantal leiding per geslacht
|
|
325
|
+
-- except: keeo
|
|
320
326
|
-- display: pie
|
|
321
327
|
-- size: third
|
|
322
328
|
-- dimensions: Geslacht
|
|
@@ -348,12 +354,17 @@ WHERE birth_date IS NOT NULL
|
|
|
348
354
|
GROUP BY YEAR(birth_date)
|
|
349
355
|
ORDER BY `Geboortejaar`
|
|
350
356
|
|
|
357
|
+
-- The leeftijdsverdeling, in the two shapes it is read in. Exactly one environment writes each of
|
|
358
|
+
-- them: the split is what a platform that asks its leden no geslacht cannot draw.
|
|
351
359
|
-- @card eenheid-leeftijd-en-geslacht
|
|
352
360
|
-- title: Aantal leden per Leeftijd en Geslacht
|
|
361
|
+
-- except: keeo
|
|
353
362
|
-- display: bar
|
|
354
363
|
-- size: full
|
|
355
364
|
-- dimensions: Leeftijd, Geslacht
|
|
356
365
|
-- metrics: Aantal leden
|
|
366
|
+
-- xscale: ordinal
|
|
367
|
+
-- xlabels: rotate-45
|
|
357
368
|
WITH leden AS (
|
|
358
369
|
-- @include deduplicated-non-platform-registrations
|
|
359
370
|
)
|
|
@@ -366,6 +377,26 @@ WHERE birth_date IS NOT NULL
|
|
|
366
377
|
GROUP BY leeftijd, `Geslacht`
|
|
367
378
|
ORDER BY leeftijd
|
|
368
379
|
|
|
380
|
+
-- @card eenheid-leden-per-leeftijd
|
|
381
|
+
-- title: Aantal leden per leeftijd
|
|
382
|
+
-- only: keeo
|
|
383
|
+
-- display: bar
|
|
384
|
+
-- size: full
|
|
385
|
+
-- dimensions: Leeftijd
|
|
386
|
+
-- metrics: Aantal leden
|
|
387
|
+
-- xscale: ordinal
|
|
388
|
+
-- xlabels: rotate-45
|
|
389
|
+
WITH leden AS (
|
|
390
|
+
-- @include deduplicated-non-platform-registrations
|
|
391
|
+
)
|
|
392
|
+
SELECT
|
|
393
|
+
leeftijd AS `Leeftijd`,
|
|
394
|
+
COUNT(DISTINCT member_id) AS `Aantal leden`
|
|
395
|
+
FROM leden
|
|
396
|
+
WHERE birth_date IS NOT NULL
|
|
397
|
+
GROUP BY leeftijd
|
|
398
|
+
ORDER BY leeftijd
|
|
399
|
+
|
|
369
400
|
-- @card eenheid-gemiddelde-leeftijd-leiding
|
|
370
401
|
-- title: Gemiddelde leeftijd leiding per Werkjaar
|
|
371
402
|
-- display: line
|
package/report/gtp.sql
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
-- @tab gtp
|
|
2
|
+
-- title: GTP per eenheid
|
|
3
|
+
-- description: De GTP-index van elke eenheid over het gekozen werkjaar en de twee werkjaren ervoor, om de eenheden te vinden die het moeilijker hebben.
|
|
4
|
+
-- filters: werkjaar, platformleden_opnemen
|
|
5
|
+
-- required: werkjaar
|
|
6
|
+
|
|
7
|
+
-- @card gtp-per-eenheid
|
|
8
|
+
-- title: GTP per eenheid over drie werkjaren
|
|
9
|
+
-- display: table
|
|
10
|
+
-- size: full
|
|
11
|
+
-- height: 16
|
|
12
|
+
-- metrics: GTP twee werkjaren eerder, GTP vorig werkjaar, GTP dit werkjaar
|
|
13
|
+
-- segments: 0, 35, 55, 75, 95, 115, 135
|
|
14
|
+
-- highlight: Opvolgen
|
|
15
|
+
-- defaults: aantal_werkjaren = 3
|
|
16
|
+
-- description: GTP staat voor Gezond Toekomst Perspectief. Een cel kleurt volgens de GTP: groen vanaf 115, rood onder 35. Een rij kleurt wanneer de eenheid opgevolgd moet worden: geel als de GTP van dit werkjaar onder 55 ligt, oranje als ze minstens 10 punten lager ligt dan twee werkjaren eerder, rood als beide gelden. Enkel eenheden met leden in het gekozen werkjaar staan in de lijst.
|
|
17
|
+
WITH leden AS (
|
|
18
|
+
-- @include deduplicated-non-platform-registrations-all-years
|
|
19
|
+
),
|
|
20
|
+
-- Zie `leden-per-leeftijdsgroep-vergelijking`: ook een jaar zonder leden telt als vorig werkjaar.
|
|
21
|
+
jaren AS (
|
|
22
|
+
SELECT
|
|
23
|
+
name,
|
|
24
|
+
MIN(startDate) AS startDate,
|
|
25
|
+
LAG(name) OVER (ORDER BY MIN(startDate)) AS vorig,
|
|
26
|
+
LAG(name, 2) OVER (ORDER BY MIN(startDate)) AS voorvorig
|
|
27
|
+
FROM registration_periods
|
|
28
|
+
GROUP BY name
|
|
29
|
+
),
|
|
30
|
+
-- The selected year, or the most recent one when the filter is empty.
|
|
31
|
+
gekozen AS (
|
|
32
|
+
SELECT name, vorig, voorvorig FROM jaren
|
|
33
|
+
WHERE 1 = 1 [[AND name = {{werkjaar}}]]
|
|
34
|
+
ORDER BY startDate DESC
|
|
35
|
+
LIMIT 1
|
|
36
|
+
),
|
|
37
|
+
gtp_per_jaar AS (
|
|
38
|
+
SELECT
|
|
39
|
+
leden.organization_id,
|
|
40
|
+
leden.`Werkjaar`,
|
|
41
|
+
MAX(leden.organization_uri) AS groepsnummer,
|
|
42
|
+
MAX(leden.`Eenheid`) AS eenheid,
|
|
43
|
+
-- An eenheid is listed under the name and number it carries in the most recent of the three years.
|
|
44
|
+
ROW_NUMBER() OVER (PARTITION BY leden.organization_id ORDER BY MIN(leden.period_start) DESC) AS recentste,
|
|
45
|
+
-- @include gtp
|
|
46
|
+
AS gtp
|
|
47
|
+
FROM leden
|
|
48
|
+
CROSS JOIN gekozen
|
|
49
|
+
WHERE leden.`Werkjaar` IN (gekozen.name, gekozen.vorig, gekozen.voorvorig)
|
|
50
|
+
GROUP BY leden.organization_id, leden.`Werkjaar`
|
|
51
|
+
),
|
|
52
|
+
per_eenheid AS (
|
|
53
|
+
SELECT
|
|
54
|
+
MAX(CASE WHEN gtp_per_jaar.recentste = 1 THEN gtp_per_jaar.groepsnummer END) AS groepsnummer,
|
|
55
|
+
MAX(CASE WHEN gtp_per_jaar.recentste = 1 THEN gtp_per_jaar.eenheid END) AS eenheid,
|
|
56
|
+
MAX(CASE WHEN gtp_per_jaar.`Werkjaar` = gekozen.voorvorig THEN gtp_per_jaar.gtp END) AS voorvorig,
|
|
57
|
+
MAX(CASE WHEN gtp_per_jaar.`Werkjaar` = gekozen.vorig THEN gtp_per_jaar.gtp END) AS vorig,
|
|
58
|
+
MAX(CASE WHEN gtp_per_jaar.`Werkjaar` = gekozen.name THEN gtp_per_jaar.gtp END) AS huidig
|
|
59
|
+
FROM gtp_per_jaar
|
|
60
|
+
CROSS JOIN gekozen
|
|
61
|
+
GROUP BY gtp_per_jaar.organization_id
|
|
62
|
+
HAVING MAX(gtp_per_jaar.`Werkjaar` = gekozen.name) = 1
|
|
63
|
+
)
|
|
64
|
+
SELECT
|
|
65
|
+
groepsnummer AS `Groepsnummer`,
|
|
66
|
+
eenheid AS `Eenheid`,
|
|
67
|
+
voorvorig AS `GTP twee werkjaren eerder`,
|
|
68
|
+
vorig AS `GTP vorig werkjaar`,
|
|
69
|
+
huidig AS `GTP dit werkjaar`,
|
|
70
|
+
CASE
|
|
71
|
+
WHEN huidig < 55 AND huidig <= voorvorig - 10 THEN 'Onder 55 en gedaald'
|
|
72
|
+
WHEN huidig < 55 THEN 'Onder 55'
|
|
73
|
+
WHEN huidig <= voorvorig - 10 THEN 'Gedaald'
|
|
74
|
+
END AS `Opvolgen`
|
|
75
|
+
FROM per_eenheid
|
|
76
|
+
-- Numeric groepsnummers in numeric order, then the others alphabetically.
|
|
77
|
+
ORDER BY
|
|
78
|
+
groepsnummer NOT REGEXP '^[0-9]+$',
|
|
79
|
+
CASE WHEN groepsnummer REGEXP '^[0-9]+$' THEN CAST(groepsnummer AS UNSIGNED) END,
|
|
80
|
+
groepsnummer
|
|
@@ -13,7 +13,14 @@ SELECT
|
|
|
13
13
|
registration_periods.name AS `Werkjaar`,
|
|
14
14
|
registration_periods.startDate AS period_start,
|
|
15
15
|
`groups`.type AS group_type,
|
|
16
|
-
|
|
16
|
+
`groups`.name AS group_name,
|
|
17
|
+
-- Een activiteit is geen leeftijdsgroep. Wie hier nog met zo'n inschrijving staat, zit dat
|
|
18
|
+
-- werkjaar in geen enkele leeftijdsgroep, dus de grafieken die de leden per leeftijdsgroep
|
|
19
|
+
-- tekenen zetten hem onder één noemer in plaats van onder de naam van het kamp zelf.
|
|
20
|
+
CASE
|
|
21
|
+
WHEN `groups`.type = 'EventRegistration' THEN 'Activiteit'
|
|
22
|
+
ELSE COALESCE(default_age_groups_with_category.name, `groups`.name)
|
|
23
|
+
END AS `Leeftijdsgroep`,
|
|
17
24
|
default_age_groups_with_category.id AS age_group_id,
|
|
18
25
|
default_age_groups_with_category.category AS age_group_category,
|
|
19
26
|
default_age_groups_with_category.minAge AS age_group_min_age,
|
|
@@ -53,6 +60,17 @@ WHERE registrations.registeredAt IS NOT NULL
|
|
|
53
60
|
OR NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = registrations.organizationId)
|
|
54
61
|
)
|
|
55
62
|
[[AND organizations.name = {{eenheid}}]]
|
|
63
|
+
-- Only the chosen werkjaar and the ones before it, for a card that gives `aantal_werkjaren` a
|
|
64
|
+
-- value. Every other card leaves it empty, which drops the clause and keeps every werkjaar.
|
|
65
|
+
[[AND registration_periods.name IN (
|
|
66
|
+
SELECT werkjaren.name FROM (
|
|
67
|
+
SELECT name, ROW_NUMBER() OVER (ORDER BY MIN(startDate) DESC) AS positie
|
|
68
|
+
FROM registration_periods
|
|
69
|
+
GROUP BY name
|
|
70
|
+
HAVING MIN(startDate) <= (SELECT MIN(startDate) FROM registration_periods WHERE name = {{werkjaar}})
|
|
71
|
+
) werkjaren
|
|
72
|
+
WHERE werkjaren.positie <= {{aantal_werkjaren}}
|
|
73
|
+
)]]
|
|
56
74
|
AND (
|
|
57
75
|
-- @include filter-registration-types
|
|
58
76
|
)
|
|
@@ -13,7 +13,14 @@ SELECT
|
|
|
13
13
|
registration_periods.name AS `Werkjaar`,
|
|
14
14
|
registration_periods.startDate AS period_start,
|
|
15
15
|
`groups`.type AS group_type,
|
|
16
|
-
|
|
16
|
+
`groups`.name AS group_name,
|
|
17
|
+
-- Een activiteit is geen leeftijdsgroep. Wie hier nog met zo'n inschrijving staat, zit dat
|
|
18
|
+
-- werkjaar in geen enkele leeftijdsgroep, dus de grafieken die de leden per leeftijdsgroep
|
|
19
|
+
-- tekenen zetten hem onder één noemer in plaats van onder de naam van het kamp zelf.
|
|
20
|
+
CASE
|
|
21
|
+
WHEN `groups`.type = 'EventRegistration' THEN 'Activiteit'
|
|
22
|
+
ELSE COALESCE(default_age_groups_with_category.name, `groups`.name)
|
|
23
|
+
END AS `Leeftijdsgroep`,
|
|
17
24
|
default_age_groups_with_category.id AS age_group_id,
|
|
18
25
|
default_age_groups_with_category.category AS age_group_category,
|
|
19
26
|
default_age_groups_with_category.minAge AS age_group_min_age,
|
|
@@ -9,6 +9,7 @@ SELECT deduplicated.* FROM (
|
|
|
9
9
|
ROW_NUMBER() OVER (
|
|
10
10
|
PARTITION BY non_platform_registrations.organization_id, non_platform_registrations.`Werkjaar`, non_platform_registrations.member_id
|
|
11
11
|
ORDER BY
|
|
12
|
+
(non_platform_registrations.group_type = 'Membership') DESC,
|
|
12
13
|
(non_platform_registrations.deactivated_at IS NULL) DESC,
|
|
13
14
|
CASE non_platform_registrations.age_group_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
14
15
|
CASE non_platform_registrations.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- description: Eén rij per lid per eenheid voor het gekozen werkjaar: de inschrijving die voor het lid spreekt.
|
|
1
|
+
-- description: Eén rij per lid per eenheid voor het gekozen werkjaar: de inschrijving die voor het lid spreekt. Een leeftijdsgroep wint van een activiteit, leiding wint van lid, en de oudste leeftijdsgroep wint bij twee.
|
|
2
2
|
WITH non_platform_registrations AS (
|
|
3
3
|
-- @include all-non-platform-registrations
|
|
4
4
|
)
|
|
@@ -8,6 +8,7 @@ SELECT deduplicated.* FROM (
|
|
|
8
8
|
ROW_NUMBER() OVER (
|
|
9
9
|
PARTITION BY non_platform_registrations.organization_id, non_platform_registrations.`Werkjaar`, non_platform_registrations.member_id
|
|
10
10
|
ORDER BY
|
|
11
|
+
(non_platform_registrations.group_type = 'Membership') DESC,
|
|
11
12
|
(non_platform_registrations.deactivated_at IS NULL) DESC,
|
|
12
13
|
CASE non_platform_registrations.age_group_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
13
14
|
CASE non_platform_registrations.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
-- description: Welke
|
|
2
|
-
`groups`.type
|
|
1
|
+
-- description: Welke inschrijvingen meetellen voor de ledenstatistieken: die in een leeftijdsgroep, en die voor een activiteit enkel bij wie dat werkjaar in geen enkele leeftijdsgroep zit. Wachtlijsten tellen nergens mee.
|
|
2
|
+
`groups`.type = 'Membership'
|
|
3
|
+
-- Een activiteit maakt iemand lid van de eenheid die ze organiseert, maar alleen als niets anders dat
|
|
4
|
+
-- al doet: wie ergens in een leeftijdsgroep zit, is daar lid en komt op de activiteit van een andere
|
|
5
|
+
-- eenheid enkel op bezoek -- meegeteld bij allebei zou hij twee keer in de cijfers staan. Wie enkel
|
|
6
|
+
-- voor een activiteit ingeschreven is, wordt nergens anders geteld en hier dus wel.
|
|
7
|
+
OR (
|
|
8
|
+
`groups`.type = 'EventRegistration'
|
|
9
|
+
AND NOT EXISTS (
|
|
10
|
+
SELECT 1
|
|
11
|
+
FROM registrations AS leeftijdsgroepinschrijving
|
|
12
|
+
JOIN `groups` AS leeftijdsgroep
|
|
13
|
+
ON leeftijdsgroep.id = leeftijdsgroepinschrijving.groupId
|
|
14
|
+
AND leeftijdsgroep.deletedAt IS NULL
|
|
15
|
+
AND leeftijdsgroep.type = 'Membership'
|
|
16
|
+
WHERE leeftijdsgroepinschrijving.memberId = registrations.memberId
|
|
17
|
+
AND leeftijdsgroepinschrijving.periodId = registrations.periodId
|
|
18
|
+
AND leeftijdsgroepinschrijving.registeredAt IS NOT NULL
|
|
19
|
+
)
|
|
20
|
+
)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- description: Wat een rij van Deelnemers_Lokale_groep telt: het aantal deelnemers, en hoeveel van hen als stam of als ondersteunend lid geleverd worden. Die twee tellen mee in het aantal en staan er enkel apart bij omdat de koepel ze zelf wil zien; het aanleversjabloon heeft geen kolom voor hen.
|
|
2
|
+
COUNT(DISTINCT deelnemers.member_id) AS `Aantal_deelnemers`,
|
|
3
|
+
COUNT(DISTINCT CASE WHEN deelnemers.subgroup_number = 1 THEN deelnemers.member_id END) AS `Waarvan Stam`,
|
|
4
|
+
COUNT(DISTINCT CASE WHEN deelnemers.subgroup_number = 2 THEN deelnemers.member_id END) AS `Waarvan Ondersteunende leden`
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- description: De aparte leeftijdsgroep die de koepel naast het type wil zien in de aanlevering, als nummer: 1 voor de stam, 2 voor de ondersteunende leden, 0 voor een gewone leeftijdsgroep. Hoe lager, hoe eerder ze wint, zodat een gewone leeftijdsgroep van allebei wint. Het type zegt waaronder ze geleverd worden: de stam bij de leden, de ondersteunende leden bij de leiding.
|
|
2
|
+
CASE all_registrations.age_group_id
|
|
3
|
+
WHEN '6fc0775e-2851-4fe1-90cd-af9c74243ccd' THEN 1 -- Stam
|
|
4
|
+
WHEN 'ac8848e9-9868-44a1-a057-2a189cce68ea' THEN 2 -- Ondersteunende leden, VZW, Steuncomité of Helpende handen
|
|
5
|
+
ELSE 0
|
|
6
|
+
END
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- description: Het type deelnemer (van all_registrations) voor de aanlevering: 2 voor leiding, 1 voor leden, 0 voor wie niet meegeteld wordt. De stam telt hier bij de leden en de ondersteunende leden bij de leiding, want het sjabloon heeft geen derde woord voor hen. Wie geen aansluiting heeft die de aanlevering meetelt, staat er sowieso niet in.
|
|
2
|
+
CASE
|
|
3
|
+
WHEN all_registrations.age_group_category = 'leader' THEN 2
|
|
4
|
+
WHEN all_registrations.age_group_id = 'ac8848e9-9868-44a1-a057-2a189cce68ea' THEN 2 -- Ondersteunende leden
|
|
5
|
+
WHEN all_registrations.age_group_category = 'child' THEN 1
|
|
6
|
+
WHEN all_registrations.age_group_id = '6fc0775e-2851-4fe1-90cd-af9c74243ccd' THEN 1 -- Stam
|
|
7
|
+
ELSE 0
|
|
8
|
+
END
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
-- description: De kenmerken waarmee het aanleversjabloon een deelnemer beschrijft: geboortejaar en geslacht, dat laatste in de letters die de metadatafiche toelaat. Eén rij van een deelnemerstabblad staat voor één combinatie ervan, dus `participant-detail-columns` noemt dezelfde kolommen.
|
|
2
|
+
YEAR(`birth_date`) AS `Geboortejaar_deelnemers`,
|
|
3
|
+
CASE `Geslacht` WHEN 'Man' THEN 'M' WHEN 'Vrouw' THEN 'V' ELSE NULL END AS `Gender_deelnemers`,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- description: De ULDK-tabel zonder de geslachten: kinderen en leiding per eenheid, voor een platform dat zijn leden geen geslacht vraagt.
|
|
2
|
+
WITH leden AS (
|
|
3
|
+
-- @include deduplicated-non-platform-registrations
|
|
4
|
+
)
|
|
5
|
+
SELECT
|
|
6
|
+
`Eenheid` AS `Name`,
|
|
7
|
+
eenheid_gemeente AS `City`,
|
|
8
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'child' THEN member_id END) AS `Aantal kinderen`,
|
|
9
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'leader' THEN member_id END) AS `Aantal leiding`
|
|
10
|
+
FROM leden
|
|
11
|
+
GROUP BY `Eenheid`, eenheid_gemeente
|