@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
|
@@ -2,32 +2,8 @@
|
|
|
2
2
|
-- title: Jeugdbewegingen
|
|
3
3
|
-- dashboard: Groepen en Deelnemers - Departement Jeugd
|
|
4
4
|
-- description: De jaarlijkse aanlevering 'Groepen en Deelnemers Jeugdbewegingen' aan het Departement Cultuur, Jeugd en Media. Eén kaart per tabblad van het sjabloon: download ze via het pijltje rechtsonder op de kaart als .xlsx en plak ze in het aanleversjabloon.
|
|
5
|
-
-- filters:
|
|
6
|
-
--
|
|
7
|
-
-- The dataset a koepel delivers every september, over the werkjaar that ended in august. One card per
|
|
8
|
-
-- sheet of the delivery template, holding the columns the koepel fills in, in the order and under the
|
|
9
|
-
-- exact names that template gives them. The columns the department fills in itself -- Werkjaar,
|
|
10
|
-
-- Type_organisatie, NIS-code -- are deliberately absent.
|
|
11
|
-
--
|
|
12
|
-
-- On a dashboard of its own, unlike every other tab here: this mirrors no page of the client's own
|
|
13
|
-
-- report, and what it is for -- an aanlevering to a government department, once a year -- has nothing
|
|
14
|
-
-- to do with the figures the ledenstatistieken are read for.
|
|
15
|
-
--
|
|
16
|
-
-- A werkjaar runs september to august, which is what a period spans here, so the scoutsjaar filter is
|
|
17
|
-
-- what picks one. No sheet carries it as a column, since the department fills that in itself, but it
|
|
18
|
-
-- decides which organisations and which deelnemers each of them holds.
|
|
19
|
-
--
|
|
20
|
-
-- The aansluiting filter reaches the two deelnemers sheets and neither of the organisatie ones:
|
|
21
|
-
-- those list which groups existed in the werkjaar, which is not a question about members. Delivering
|
|
22
|
-
-- under a chosen aansluiting therefore hands the department groups whose deelnemers were counted
|
|
23
|
-
-- under it only -- the aanlevering itself is filed with the filter empty.
|
|
24
|
-
--
|
|
25
|
-
-- What the ledenstatistieken offer as "Ingeschreven voor" is not offered here. The department counts
|
|
26
|
-
-- the deelnemers of a jeugdbeweging: someone waiting for a place has not joined one, and someone who
|
|
27
|
-
-- came to a single activity is a deelnemer of that activity rather than of the group that held it.
|
|
28
|
-
-- Both sheets therefore say `group_type = 'Membership'` themselves rather than leaving it to a filter
|
|
29
|
-
-- this dashboard does not show -- an unanswered filter counts every registration, which is the wrong
|
|
30
|
-
-- way for a sheet to fail.
|
|
5
|
+
-- filters: werkjaar
|
|
6
|
+
-- required: werkjaar
|
|
31
7
|
|
|
32
8
|
-- @card organisatie-bovenlokaal
|
|
33
9
|
-- title: Organisatie_Bovenlokaal
|
|
@@ -35,23 +11,15 @@
|
|
|
35
11
|
-- size: full
|
|
36
12
|
-- columns: ID_Organisatie, Naam_Organisatie
|
|
37
13
|
-- description: Tabblad 'Organisatie_Bovenlokaal': de bovenlokale of nationale ondersteuningsstructuur, namelijk de eigen organisatie van de koepel.
|
|
38
|
-
--
|
|
39
|
-
-- One row: the organization the platform runs itself, which `platform.membershipOrganizationId`
|
|
40
|
-
-- points at. Everything else in the administration is a local group, and the ploegen of the koepel
|
|
41
|
-
-- count as a single structure, so this sheet holds exactly that one organization.
|
|
42
|
-
--
|
|
43
|
-
-- Named as it stood in the werkjaar, which is why the name comes from `organizations` and not from
|
|
44
|
-
-- the platform: a unit's name is recorded per period, and a rename lands in the year it happened in.
|
|
45
|
-
-- A werkjaar the koepel's own organization holds no row for -- one it had no registrations in --
|
|
46
|
-
-- delivers nothing rather than a name from another year.
|
|
47
14
|
SELECT
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
FROM organizations
|
|
51
|
-
JOIN platform
|
|
52
|
-
JOIN registration_periods
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
organizations.uri AS `ID_Organisatie`,
|
|
16
|
+
organizations.name AS `Naam_Organisatie`
|
|
17
|
+
FROM organizations
|
|
18
|
+
JOIN platform ON platform.membershipOrganizationId = organizations.id
|
|
19
|
+
JOIN registration_periods ON registration_periods.id = organizations.periodId [[AND registration_periods.name = {{werkjaar}}]]
|
|
20
|
+
WHERE organizations.active = 1
|
|
21
|
+
GROUP BY organizations.uri, organizations.name
|
|
22
|
+
ORDER BY organizations.name
|
|
55
23
|
|
|
56
24
|
-- @card deelnemers-bovenlokaal
|
|
57
25
|
-- title: Deelnemers_Bovenlokaal
|
|
@@ -59,40 +27,23 @@ ORDER BY o.name
|
|
|
59
27
|
-- size: full
|
|
60
28
|
-- columns: ID_Organisatie, Geboortejaar_deelnemers, Gender_deelnemers, Aantal_deelnemers
|
|
61
29
|
-- description: Tabblad 'Deelnemers_Bovenlokaal': de structuurvrijwilligers van de koepel, per geboortejaar en geslacht, met een aansluiting in dat werkjaar. Unieke personen, geen inschrijvingen: zo vraagt de metadatafiche het voor de nationale ploegen.
|
|
62
|
-
--
|
|
63
|
-
|
|
64
|
-
--
|
|
65
|
-
|
|
66
|
-
-- a registration with an aansluiting behind it is what this counts.
|
|
67
|
-
--
|
|
68
|
-
-- Unique people rather than registrations, which is what the metadatafiche asks for at this one
|
|
69
|
-
-- organization: the national ploegen count as a single structure, so someone in two of them is one
|
|
70
|
-
-- deelnemer. Someone who is also leiding at a local group keeps counting there as well, on the sheet
|
|
71
|
-
-- of that group -- the two are counted at different organizations.
|
|
72
|
-
--
|
|
73
|
-
-- An empty cell wherever the administration has no answer, which is what the metadatafiche asks for
|
|
74
|
-
-- rather than a value of its own: a member without a date of birth gets no geboortejaar, and one
|
|
75
|
-
-- whose geslacht was never filled in gets no letter, since the CASE has no ELSE to fall back on.
|
|
76
|
-
--
|
|
77
|
-
-- Read from `all_registrations` rather than from `facts`, on two counts. The ledenstatistieken leave
|
|
78
|
-
-- this organization out and this sheet is the one thing that is about it; and they leave out a
|
|
79
|
-
-- registration that was cancelled during the year, while the department counts everyone who was
|
|
80
|
-
-- registered at some point in the werkjaar -- someone who stopped in november was a deelnemer of that
|
|
81
|
-
-- year, and the aansluiting the koepel charged them says so.
|
|
82
|
-
-- @include facts
|
|
30
|
+
-- The rows before the koepel is dropped: this sheet is about nothing else.
|
|
31
|
+
WITH all_registrations AS (
|
|
32
|
+
-- @include all-registrations
|
|
33
|
+
)
|
|
83
34
|
SELECT
|
|
84
|
-
|
|
85
|
-
YEAR(
|
|
86
|
-
CASE
|
|
87
|
-
COUNT(DISTINCT
|
|
88
|
-
FROM all_registrations
|
|
89
|
-
JOIN platform
|
|
35
|
+
all_registrations.organization_uri AS `ID_Organisatie`,
|
|
36
|
+
YEAR(all_registrations.birth_date) AS `Geboortejaar_deelnemers`,
|
|
37
|
+
CASE all_registrations.`Geslacht` WHEN 'Man' THEN 'M' WHEN 'Vrouw' THEN 'V' ELSE NULL END AS `Gender_deelnemers`,
|
|
38
|
+
COUNT(DISTINCT all_registrations.member_id) AS `Aantal_deelnemers`
|
|
39
|
+
FROM all_registrations
|
|
40
|
+
JOIN platform ON platform.membershipOrganizationId = all_registrations.organization_id
|
|
90
41
|
WHERE
|
|
91
|
-
-- @include
|
|
42
|
+
-- @include filter-has-delivery-membership
|
|
92
43
|
-- A ploeg of the koepel, never one of the national events it also runs its registrations for: those
|
|
93
44
|
-- are open to the deelnemers of every group, and counted here every one of them would be delivered
|
|
94
45
|
-- as a structuurvrijwilliger of the bovenlokale structuur.
|
|
95
|
-
AND
|
|
46
|
+
AND all_registrations.group_type = 'Membership'
|
|
96
47
|
GROUP BY `ID_Organisatie`, `Geboortejaar_deelnemers`, `Gender_deelnemers`
|
|
97
48
|
ORDER BY `Geboortejaar_deelnemers`, `Gender_deelnemers`
|
|
98
49
|
|
|
@@ -102,28 +53,14 @@ ORDER BY `Geboortejaar_deelnemers`, `Gender_deelnemers`
|
|
|
102
53
|
-- size: full
|
|
103
54
|
-- columns: ID_Organisatie, Naam_Organisatie, Postcode
|
|
104
55
|
-- description: Tabblad 'Organisatie_Lokale_groep': elke lokale jeugdbewegingsgroep met haar postcode. De eigen organisatie van de koepel staat hier niet in, die hoort op het tabblad Organisatie_Bovenlokaal. DCJM vult zelf Werkjaar, Type_organisatie en NIS-code aan.
|
|
105
|
-
--
|
|
106
|
-
-- Every organization in the administration except the one the platform runs itself: that one is the
|
|
107
|
-
-- bovenlokale structuur of the sheet above, and the department reads one organization per row across
|
|
108
|
-
-- the two, so a unit on both would be a unit counted twice. Dropped on
|
|
109
|
-
-- `platform.membershipOrganizationId`, the way every card of the ledenstatistieken drops it.
|
|
110
|
-
--
|
|
111
|
-
-- Read from `organizations` rather than from the members: what the sheet lists is which groups
|
|
112
|
-
-- existed in that werkjaar, so a unit that registered nobody is a group with no deelnemers rather
|
|
113
|
-
-- than no group. That also means a unit that has stopped keeps being delivered while its year is
|
|
114
|
-
-- still open, since a row here is not evidence of anything having happened.
|
|
115
|
-
--
|
|
116
|
-
-- The template's datatype for a postcode is a four digit number, and what the administration holds is
|
|
117
|
-
-- free text: a foreign postcode, or an entire address typed into the box. Anything that is not four
|
|
118
|
-
-- digits leaves the cell empty -- a required field the koepel can see and fill in -- rather than
|
|
119
|
-
-- delivering a number that is wrong.
|
|
120
56
|
SELECT
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
CASE WHEN
|
|
124
|
-
FROM organizations
|
|
125
|
-
JOIN registration_periods
|
|
126
|
-
WHERE
|
|
57
|
+
organizations.uri AS `ID_Organisatie`,
|
|
58
|
+
organizations.name AS `Naam_Organisatie`,
|
|
59
|
+
CASE WHEN organizations.postalCode REGEXP '^[0-9]{4}$' THEN CAST(organizations.postalCode AS UNSIGNED) END AS `Postcode`
|
|
60
|
+
FROM organizations
|
|
61
|
+
JOIN registration_periods ON registration_periods.id = organizations.periodId [[AND registration_periods.name = {{werkjaar}}]]
|
|
62
|
+
WHERE organizations.active = 1
|
|
63
|
+
AND NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = organizations.id)
|
|
127
64
|
GROUP BY `ID_Organisatie`, `Naam_Organisatie`, `Postcode`
|
|
128
65
|
ORDER BY `Naam_Organisatie`
|
|
129
66
|
|
|
@@ -132,90 +69,46 @@ ORDER BY `Naam_Organisatie`
|
|
|
132
69
|
-- display: table
|
|
133
70
|
-- size: full
|
|
134
71
|
-- columns: ID_Organisatie, Type_deelnemers, Geboortejaar_deelnemers, Gender_deelnemers, Aantal_deelnemers
|
|
135
|
-
-- description: Tabblad 'Deelnemers_Lokale_groep': de leden en de leiding van elke lokale groep, per geboortejaar en geslacht, met een aansluiting in dat werkjaar. Wie leiding is in de ene
|
|
136
|
-
-- description@ravot: Tabblad 'Deelnemers_Lokale_groep': de leden en de leiding van elke lokale groep, per geboortejaar en geslacht, met een aansluiting in dat werkjaar. De
|
|
137
|
-
|
|
138
|
-
--
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-- Read from `tak_category`, what the takken were recorded as, and never from `effective_category`,
|
|
142
|
-
-- which the ledenstatistieken split by. That one falls back to the ages so nobody drops out of a
|
|
143
|
-
-- total, and the ages cannot tell leiding from anything: a leider of seventeen reads as a kind and
|
|
144
|
-
-- one of twenty as nothing at all. A sheet that goes to a department may not guess, so a tak nobody
|
|
145
|
-
-- has categorised delivers nobody here -- visibly missing rather than quietly counted as leden.
|
|
146
|
-
--
|
|
147
|
-
-- Only the two the template allows are delivered. A tak recorded as volwassenen is neither, and its
|
|
148
|
-
-- members are left out of the sheet entirely; the metadatafiche does count the volwassen
|
|
149
|
-
-- begeleiders, kassabeheerders and secretarissen of a group as leiding, so a koepel with such a tak
|
|
150
|
-
-- has to say whether it is leiding rather than leaving it as volwassenen. Which of the two a
|
|
151
|
-
-- registration is worth is `type-deelnemers.sql`, since a koepel with a tak the categories cannot
|
|
152
|
-
-- say this of -- the ondersteunende leden of ravot -- names it there and nowhere else.
|
|
153
|
-
--
|
|
154
|
-
-- The numbers that fragment gives rank rather than label: leiding beats leden, and leden beats a tak
|
|
155
|
-
-- that is neither, so the MAX below picks the strongest thing any registration of that member says.
|
|
156
|
-
--
|
|
157
|
-
-- Decided once per member per group, before anything is counted. Someone can be a lid in one tak and
|
|
158
|
-
-- leiding in another of the same unit, and the metadatafiche is explicit that they are leiding there
|
|
159
|
-
-- and not a lid; counted per registration they would be one person delivered in both rows, and the
|
|
160
|
-
-- group would report more deelnemers than it has. The date of birth and the geslacht are taken the
|
|
161
|
-
-- same way, so that a member whose answer was corrected between two werkjaren cannot split into two
|
|
162
|
-
-- people either.
|
|
163
|
-
--
|
|
164
|
-
-- Decided by the registrations that still stand, and by the cancelled ones only when none of them do.
|
|
165
|
-
-- A cancelled registration says someone was there, not what they were: an administrator who puts a
|
|
166
|
-
-- lid in the Leiding tak by mistake and undoes it would otherwise leave them leiding for the rest of
|
|
167
|
-
-- the werkjaar, while the registration they really hold says what they are. A member whose
|
|
168
|
-
-- registrations at the group were all cancelled -- someone who left during the year -- has nothing
|
|
169
|
-
-- else to be read from, and is what the cancelled ones are kept for.
|
|
170
|
-
--
|
|
171
|
-
-- One row per member per group is also what the counting asks for. The metadatafiche counts
|
|
172
|
-
-- inschrijvingen rather than unique inschrijvers, and says what it means by that: someone registered
|
|
173
|
-
-- at two groups counts at both. Within one group they are one deelnemer, however many takken they are
|
|
174
|
-
-- registered in.
|
|
175
|
-
--
|
|
176
|
-
-- Read from `all_registrations`, which keeps the registrations that were cancelled during the year:
|
|
177
|
-
-- someone who stopped in november was a deelnemer of that werkjaar. The koepel's own organization is
|
|
178
|
-
-- dropped here rather than by reading `facts`, since that would drop those registrations with it.
|
|
179
|
-
-- @include facts
|
|
180
|
-
, inschrijvingen AS (
|
|
72
|
+
-- description: Tabblad 'Deelnemers_Lokale_groep': de leden en de leiding van elke lokale groep, per geboortejaar en geslacht, met een aansluiting in dat werkjaar. Wie leiding is in de ene leeftijdsgroep en lid in de andere, telt enkel als leiding. Leeftijdsgroepen zonder categorie leveren niemand: vul die eerst aan.
|
|
73
|
+
-- description@ravot: Tabblad 'Deelnemers_Lokale_groep': de leden en de leiding van elke lokale groep, per geboortejaar en geslacht, met een aansluiting in dat werkjaar. De leeftijdsgroep 'Ondersteunende leden' telt hier mee als leiding. Wie leiding is in de ene leeftijdsgroep en lid in de andere, telt enkel als leiding. Leeftijdsgroepen zonder categorie leveren niemand: vul die eerst aan.
|
|
74
|
+
WITH all_registrations AS (
|
|
75
|
+
-- @include all-registrations
|
|
76
|
+
),
|
|
77
|
+
inschrijvingen AS (
|
|
181
78
|
SELECT
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
-- @include type
|
|
79
|
+
all_registrations.organization_uri,
|
|
80
|
+
all_registrations.member_id,
|
|
81
|
+
all_registrations.birth_date,
|
|
82
|
+
all_registrations.`Geslacht`,
|
|
83
|
+
all_registrations.deactivated_at,
|
|
84
|
+
-- @include participant-type
|
|
188
85
|
AS type_number
|
|
189
|
-
FROM all_registrations
|
|
86
|
+
FROM all_registrations
|
|
190
87
|
WHERE
|
|
191
|
-
-- @include
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
-- consequence of a group nobody categorised rather than a rule, and a koepel that categorises
|
|
195
|
-
-- one of its wachtlijsten would start delivering the people waiting on it as leden.
|
|
196
|
-
AND f.group_type = 'Membership'
|
|
197
|
-
AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = f.organization_id)
|
|
88
|
+
-- @include filter-has-delivery-membership
|
|
89
|
+
AND all_registrations.group_type = 'Membership'
|
|
90
|
+
AND NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = all_registrations.organization_id)
|
|
198
91
|
),
|
|
199
92
|
deelnemers AS (
|
|
200
93
|
SELECT
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
MAX(
|
|
204
|
-
MAX(
|
|
94
|
+
inschrijvingen.organization_uri,
|
|
95
|
+
inschrijvingen.member_id,
|
|
96
|
+
MAX(inschrijvingen.birth_date) AS birth_date,
|
|
97
|
+
MAX(inschrijvingen.`Geslacht`) AS `Geslacht`,
|
|
205
98
|
COALESCE(
|
|
206
|
-
MAX(CASE WHEN
|
|
207
|
-
MAX(
|
|
99
|
+
MAX(CASE WHEN inschrijvingen.deactivated_at IS NULL THEN inschrijvingen.type_number END),
|
|
100
|
+
MAX(inschrijvingen.type_number)
|
|
208
101
|
) AS type_number
|
|
209
|
-
FROM inschrijvingen
|
|
210
|
-
GROUP BY
|
|
102
|
+
FROM inschrijvingen
|
|
103
|
+
GROUP BY inschrijvingen.organization_uri, inschrijvingen.member_id
|
|
211
104
|
)
|
|
212
105
|
SELECT
|
|
213
|
-
|
|
214
|
-
CASE WHEN
|
|
215
|
-
YEAR(
|
|
216
|
-
CASE
|
|
217
|
-
COUNT(DISTINCT
|
|
218
|
-
FROM deelnemers
|
|
219
|
-
|
|
106
|
+
deelnemers.organization_uri AS `ID_Organisatie`,
|
|
107
|
+
CASE WHEN deelnemers.type_number = 2 THEN 'leiding' ELSE 'leden' END AS `Type_deelnemers`,
|
|
108
|
+
YEAR(deelnemers.birth_date) AS `Geboortejaar_deelnemers`,
|
|
109
|
+
CASE deelnemers.`Geslacht` WHEN 'Man' THEN 'M' WHEN 'Vrouw' THEN 'V' ELSE NULL END AS `Gender_deelnemers`,
|
|
110
|
+
COUNT(DISTINCT deelnemers.member_id) AS `Aantal_deelnemers`
|
|
111
|
+
FROM deelnemers
|
|
112
|
+
WHERE deelnemers.type_number > 0
|
|
220
113
|
GROUP BY `ID_Organisatie`, `Type_deelnemers`, `Geboortejaar_deelnemers`, `Gender_deelnemers`
|
|
221
114
|
ORDER BY `ID_Organisatie`, `Type_deelnemers`, `Geboortejaar_deelnemers`, `Gender_deelnemers`
|
package/report/nationaal.sql
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
-- @tab nationaal
|
|
2
2
|
-- title: Nationaal
|
|
3
|
-
-- description: Ledenaantallen over het hele platform voor het gekozen
|
|
4
|
-
-- filters:
|
|
3
|
+
-- description: Ledenaantallen over het hele platform voor het gekozen werkjaar.
|
|
4
|
+
-- filters: werkjaar, platformleden_opnemen
|
|
5
|
+
-- required: werkjaar
|
|
5
6
|
|
|
6
7
|
-- @card aantal-eenheden
|
|
7
8
|
-- title: Aantal eenheden
|
|
8
9
|
-- display: scalar
|
|
9
10
|
-- size: sixth
|
|
10
|
-
|
|
11
|
-
-- @include
|
|
11
|
+
WITH leden AS (
|
|
12
|
+
-- @include deduplicated-non-platform-registrations
|
|
13
|
+
)
|
|
12
14
|
SELECT COUNT(DISTINCT organization_id) AS `Aantal eenheden` FROM leden
|
|
13
15
|
|
|
14
16
|
-- @card totaal-leden
|
|
15
17
|
-- title: Totaal leden
|
|
16
18
|
-- display: scalar
|
|
17
19
|
-- size: sixth
|
|
18
|
-
|
|
19
|
-
-- @include
|
|
20
|
+
WITH leden AS (
|
|
21
|
+
-- @include deduplicated-non-platform-registrations
|
|
22
|
+
)
|
|
20
23
|
SELECT COUNT(DISTINCT member_id) AS `Totaal leden` FROM leden
|
|
21
24
|
|
|
22
25
|
-- @card aantal-kinderen
|
|
23
26
|
-- title: Aantal kinderen
|
|
24
27
|
-- display: scalar
|
|
25
28
|
-- size: sixth
|
|
26
|
-
|
|
27
|
-
-- @include
|
|
29
|
+
WITH leden AS (
|
|
30
|
+
-- @include deduplicated-non-platform-registrations
|
|
31
|
+
)
|
|
28
32
|
SELECT COUNT(DISTINCT member_id) AS `Aantal kinderen` FROM leden WHERE effective_category = 'child'
|
|
29
33
|
|
|
30
34
|
-- @card aantal-leiding
|
|
31
35
|
-- title: Aantal leiding
|
|
32
36
|
-- display: scalar
|
|
33
37
|
-- size: sixth
|
|
34
|
-
|
|
35
|
-
-- @include
|
|
38
|
+
WITH leden AS (
|
|
39
|
+
-- @include deduplicated-non-platform-registrations
|
|
40
|
+
)
|
|
36
41
|
SELECT COUNT(DISTINCT member_id) AS `Aantal leiding` FROM leden WHERE effective_category = 'leader'
|
|
37
42
|
|
|
38
43
|
-- @card aantal-volwassenen
|
|
39
44
|
-- title: Aantal volwassenen
|
|
40
45
|
-- display: scalar
|
|
41
46
|
-- size: sixth
|
|
42
|
-
|
|
43
|
-
-- @include
|
|
47
|
+
WITH leden AS (
|
|
48
|
+
-- @include deduplicated-non-platform-registrations
|
|
49
|
+
)
|
|
44
50
|
SELECT COUNT(DISTINCT member_id) AS `Aantal volwassenen` FROM leden WHERE effective_category = 'adult'
|
|
45
51
|
|
|
46
52
|
-- @card leden-per-eenheid
|
|
@@ -53,8 +59,9 @@ SELECT COUNT(DISTINCT member_id) AS `Aantal volwassenen` FROM leden WHERE effect
|
|
|
53
59
|
-- description: GTP staat voor Gezond Toekomst Perspectief. Idealiter scoort een eenheid 100 of meer.
|
|
54
60
|
-- Rechtop, niet schuin: Metabase laat een label vallen zodra het het vorige raakt, en schuin heeft
|
|
55
61
|
-- een naam per eenheid daar net te weinig plaats voor.
|
|
56
|
-
|
|
57
|
-
-- @include
|
|
62
|
+
WITH leden AS (
|
|
63
|
+
-- @include deduplicated-non-platform-registrations
|
|
64
|
+
)
|
|
58
65
|
SELECT
|
|
59
66
|
`Eenheid`,
|
|
60
67
|
COUNT(DISTINCT member_id) AS `Aantal leden`,
|
|
@@ -64,38 +71,39 @@ FROM leden
|
|
|
64
71
|
GROUP BY `Eenheid`
|
|
65
72
|
ORDER BY `Aantal leden` DESC
|
|
66
73
|
|
|
67
|
-
-- @card leden-per-
|
|
68
|
-
-- title: Vergelijking aantal leden per
|
|
74
|
+
-- @card leden-per-leeftijdsgroep-vergelijking
|
|
75
|
+
-- title: Vergelijking aantal leden per leeftijdsgroep met vorig werkjaar
|
|
69
76
|
-- display: bar
|
|
70
77
|
-- size: half
|
|
71
|
-
-- dimensions:
|
|
78
|
+
-- dimensions: Leeftijdsgroep
|
|
72
79
|
-- metrics: Aantal leden dit jaar, Aantal leden vorig jaar
|
|
73
80
|
-- xlabels: rotate-45
|
|
74
|
-
|
|
75
|
-
-- @include
|
|
76
|
-
|
|
81
|
+
WITH leden AS (
|
|
82
|
+
-- @include deduplicated-non-platform-registrations-all-years
|
|
83
|
+
),
|
|
84
|
+
-- Zie `includes/years-with-members.sql`: het werkjaar is de naam, niet het id. Hier tellen ook de jaren zonder
|
|
77
85
|
-- leden mee, want een vergelijking met een leeg jaar is nog steeds een geldige vergelijking.
|
|
78
|
-
|
|
86
|
+
jaren AS (
|
|
79
87
|
SELECT name, MIN(startDate) AS startDate, LAG(name) OVER (ORDER BY MIN(startDate)) AS vorig
|
|
80
88
|
FROM registration_periods
|
|
81
89
|
GROUP BY name
|
|
82
|
-
)
|
|
90
|
+
),
|
|
83
91
|
-- The selected year, or the most recent one when the filter is empty, plus the year before it.
|
|
84
|
-
|
|
92
|
+
gekozen AS (
|
|
85
93
|
SELECT name, vorig FROM jaren
|
|
86
|
-
WHERE 1 = 1 [[AND name = {{
|
|
94
|
+
WHERE 1 = 1 [[AND name = {{werkjaar}}]]
|
|
87
95
|
ORDER BY startDate DESC
|
|
88
96
|
LIMIT 1
|
|
89
97
|
)
|
|
90
98
|
SELECT
|
|
91
|
-
|
|
92
|
-
COUNT(DISTINCT CASE WHEN
|
|
93
|
-
COUNT(DISTINCT CASE WHEN
|
|
94
|
-
FROM leden
|
|
95
|
-
CROSS JOIN gekozen
|
|
96
|
-
WHERE
|
|
97
|
-
GROUP BY
|
|
98
|
-
ORDER BY MIN(COALESCE(
|
|
99
|
+
leden.`Leeftijdsgroep`,
|
|
100
|
+
COUNT(DISTINCT CASE WHEN leden.`Werkjaar` = gekozen.name THEN leden.member_id END) AS `Aantal leden dit jaar`,
|
|
101
|
+
COUNT(DISTINCT CASE WHEN leden.`Werkjaar` = gekozen.vorig THEN leden.member_id END) AS `Aantal leden vorig jaar`
|
|
102
|
+
FROM leden
|
|
103
|
+
CROSS JOIN gekozen
|
|
104
|
+
WHERE leden.`Werkjaar` IN (gekozen.name, gekozen.vorig)
|
|
105
|
+
GROUP BY leden.`Leeftijdsgroep`
|
|
106
|
+
ORDER BY MIN(COALESCE(leden.age_group_min_age, 99)), leden.`Leeftijdsgroep`
|
|
99
107
|
|
|
100
108
|
-- @card leden-per-geslacht
|
|
101
109
|
-- title: Aantal leden per geslacht
|
|
@@ -103,8 +111,9 @@ ORDER BY MIN(COALESCE(f.tak_min_age, 99)), f.`Tak`
|
|
|
103
111
|
-- size: half
|
|
104
112
|
-- dimensions: Geslacht
|
|
105
113
|
-- metrics: Aantal leden
|
|
106
|
-
|
|
107
|
-
-- @include
|
|
114
|
+
WITH leden AS (
|
|
115
|
+
-- @include deduplicated-non-platform-registrations
|
|
116
|
+
)
|
|
108
117
|
SELECT `Geslacht`, COUNT(DISTINCT member_id) AS `Aantal leden`
|
|
109
118
|
FROM leden
|
|
110
119
|
GROUP BY `Geslacht`
|
|
@@ -119,17 +128,20 @@ ORDER BY `Aantal leden` DESC
|
|
|
119
128
|
-- dimensions: Postcode
|
|
120
129
|
-- metrics: Aantal leden
|
|
121
130
|
-- description: Een punt per postcode. Een postcode zonder coordinaat in `postal_codes` telt wel mee, maar staat niet op de kaart.
|
|
122
|
-
|
|
123
|
-
-- @include
|
|
124
|
-
|
|
131
|
+
WITH leden AS (
|
|
132
|
+
-- @include deduplicated-non-platform-registrations
|
|
133
|
+
),
|
|
134
|
+
postcode_coordinaten AS (
|
|
135
|
+
-- @include postal-code-coordinates
|
|
136
|
+
)
|
|
125
137
|
SELECT
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
COUNT(DISTINCT
|
|
130
|
-
FROM leden
|
|
131
|
-
LEFT JOIN postcode_coordinaten
|
|
132
|
-
GROUP BY
|
|
138
|
+
leden.postcode AS `Postcode`,
|
|
139
|
+
postcode_coordinaten.latitude AS `Breedtegraad`,
|
|
140
|
+
postcode_coordinaten.longitude AS `Lengtegraad`,
|
|
141
|
+
COUNT(DISTINCT leden.member_id) AS `Aantal leden`
|
|
142
|
+
FROM leden
|
|
143
|
+
LEFT JOIN postcode_coordinaten ON postcode_coordinaten.postalCode = leden.postcode
|
|
144
|
+
GROUP BY leden.postcode, postcode_coordinaten.latitude, postcode_coordinaten.longitude
|
|
133
145
|
ORDER BY `Aantal leden` DESC
|
|
134
146
|
|
|
135
147
|
-- @card leden-per-geboortejaar
|
|
@@ -138,8 +150,9 @@ ORDER BY `Aantal leden` DESC
|
|
|
138
150
|
-- size: half
|
|
139
151
|
-- dimensions: Geboortejaar
|
|
140
152
|
-- metrics: Aantal kinderen, Aantal leiding, Aantal volwassenen
|
|
141
|
-
|
|
142
|
-
-- @include
|
|
153
|
+
WITH leden AS (
|
|
154
|
+
-- @include deduplicated-non-platform-registrations
|
|
155
|
+
)
|
|
143
156
|
SELECT
|
|
144
157
|
YEAR(birth_date) AS `Geboortejaar`,
|
|
145
158
|
COUNT(DISTINCT CASE WHEN effective_category = 'child' THEN member_id END) AS `Aantal kinderen`,
|
|
@@ -156,44 +169,50 @@ ORDER BY `Geboortejaar`
|
|
|
156
169
|
-- size: half
|
|
157
170
|
-- dimensions: Type lidgeld
|
|
158
171
|
-- metrics: Aantal leden
|
|
159
|
-
|
|
160
|
-
-- @include
|
|
172
|
+
WITH leden AS (
|
|
173
|
+
-- @include deduplicated-non-platform-registrations
|
|
174
|
+
)
|
|
161
175
|
SELECT
|
|
162
|
-
-- @include
|
|
176
|
+
-- @include membership-fee-type
|
|
163
177
|
AS `Type lidgeld`,
|
|
164
|
-
COUNT(DISTINCT
|
|
165
|
-
FROM member_platform_memberships
|
|
166
|
-
--
|
|
167
|
-
--
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
COUNT(DISTINCT member_platform_memberships.memberId) AS `Aantal leden`
|
|
179
|
+
FROM member_platform_memberships
|
|
180
|
+
-- Het lidgeld van een lid in het jaar waarin het lid was, als één join op het paar. Niet als een
|
|
181
|
+
-- IN-subquery per kolom: `leden` wordt dan per subquery opnieuw opgebouwd en MySQL hasht die twee
|
|
182
|
+
-- resultaten tegen elkaar, waarmee de kaart niet meer laadt. Het paar is meteen ook wat de kaart
|
|
183
|
+
-- telt -- een lidgeld uit een jaar waarin dat lid geen lid was, hoort er niet bij.
|
|
184
|
+
JOIN (SELECT DISTINCT member_id, period_id FROM leden) leden_periodes
|
|
185
|
+
ON leden_periodes.member_id = member_platform_memberships.memberId
|
|
186
|
+
AND leden_periodes.period_id = member_platform_memberships.periodId
|
|
187
|
+
WHERE member_platform_memberships.deletedAt IS NULL
|
|
188
|
+
-- Geen lidmaatschap bij de koepel zelf zolang de dashboardfilter die organisatie weglaat.
|
|
189
|
+
AND (
|
|
190
|
+
{{platformleden_opnemen}}
|
|
191
|
+
OR NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = member_platform_memberships.organizationId)
|
|
192
|
+
)
|
|
193
|
+
AND (
|
|
194
|
+
-- @include filter-statistics-memberships
|
|
195
|
+
)
|
|
196
|
+
GROUP BY member_platform_memberships.reducedPrice
|
|
179
197
|
ORDER BY `Aantal leden` DESC
|
|
180
198
|
|
|
181
|
-
-- @card leden-per-
|
|
182
|
-
-- title: Aantal leden per
|
|
199
|
+
-- @card leden-per-werkjaar
|
|
200
|
+
-- title: Aantal leden per werkjaar
|
|
183
201
|
-- display: line
|
|
184
202
|
-- size: full
|
|
185
|
-
-- dimensions:
|
|
203
|
+
-- dimensions: Werkjaar
|
|
186
204
|
-- metrics: Totaal leden, Aantal kinderen, Aantal leiding, Aantal volwassenen
|
|
187
|
-
|
|
188
|
-
-- @include
|
|
205
|
+
WITH leden AS (
|
|
206
|
+
-- @include deduplicated-non-platform-registrations-all-years
|
|
207
|
+
)
|
|
189
208
|
SELECT
|
|
190
|
-
`
|
|
209
|
+
`Werkjaar`,
|
|
191
210
|
COUNT(DISTINCT member_id) AS `Totaal leden`,
|
|
192
211
|
COUNT(DISTINCT CASE WHEN effective_category = 'child' THEN member_id END) AS `Aantal kinderen`,
|
|
193
212
|
COUNT(DISTINCT CASE WHEN effective_category = 'leader' THEN member_id END) AS `Aantal leiding`,
|
|
194
213
|
COUNT(DISTINCT CASE WHEN effective_category = 'adult' THEN member_id END) AS `Aantal volwassenen`
|
|
195
214
|
FROM leden
|
|
196
|
-
GROUP BY `
|
|
215
|
+
GROUP BY `Werkjaar`
|
|
197
216
|
ORDER BY MIN(period_start)
|
|
198
217
|
|
|
199
218
|
-- @card percentage-blijvers-per-eenheid
|
|
@@ -203,15 +222,20 @@ ORDER BY MIN(period_start)
|
|
|
203
222
|
-- dimensions: Eenheid
|
|
204
223
|
-- metrics: Percentage blijvers
|
|
205
224
|
-- xlabels: rotate-90
|
|
206
|
-
-- description: Van de leden in het gekozen
|
|
225
|
+
-- description: Van de leden in het gekozen werkjaar, het percentage dat het werkjaar erna nog lid is, per eenheid waar ze in het gekozen jaar zaten. Links = laagste ledenbehoud. Het laatste werkjaar staat er niet bij: het jaar erna moet eerst bestaan.
|
|
207
226
|
-- Rechtop, om dezelfde reden als bij de grafiek met het aantal leden per eenheid.
|
|
208
|
-
|
|
209
|
-
-- @include
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
227
|
+
WITH leden AS (
|
|
228
|
+
-- @include deduplicated-non-platform-registrations-all-years
|
|
229
|
+
),
|
|
230
|
+
leden_per_jaar AS (
|
|
231
|
+
-- @include members-per-year
|
|
232
|
+
),
|
|
233
|
+
jaren AS (
|
|
234
|
+
-- @include years-with-members
|
|
235
|
+
),
|
|
236
|
+
gekozen AS (
|
|
213
237
|
SELECT name, volgend FROM jaren
|
|
214
|
-
WHERE volgend IS NOT NULL [[AND name = {{
|
|
238
|
+
WHERE volgend IS NOT NULL [[AND name = {{werkjaar}}]]
|
|
215
239
|
ORDER BY startDate DESC
|
|
216
240
|
LIMIT 1
|
|
217
241
|
)
|
|
@@ -220,10 +244,10 @@ ORDER BY MIN(period_start)
|
|
|
220
244
|
SELECT
|
|
221
245
|
huidig.`Eenheid`,
|
|
222
246
|
ROUND(100 * COUNT(DISTINCT gebleven.member_id) / COUNT(DISTINCT huidig.member_id), 1) AS `Percentage blijvers`
|
|
223
|
-
FROM gekozen
|
|
224
|
-
JOIN leden huidig ON huidig.`
|
|
247
|
+
FROM gekozen
|
|
248
|
+
JOIN leden huidig ON huidig.`Werkjaar` = gekozen.name
|
|
225
249
|
LEFT JOIN leden_per_jaar gebleven
|
|
226
|
-
ON gebleven.`
|
|
250
|
+
ON gebleven.`Werkjaar` = gekozen.volgend
|
|
227
251
|
AND gebleven.member_id = huidig.member_id
|
|
228
252
|
GROUP BY huidig.`Eenheid`
|
|
229
253
|
ORDER BY `Percentage blijvers`
|