@stamhoofd/metabase 2.148.0 → 2.149.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.
@@ -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: scoutsjaar, aansluiting
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: scoutsjaar
6
+ -- required: scoutsjaar
31
7
 
32
8
  -- @card organisatie-bovenlokaal
33
9
  -- title: Organisatie_Bovenlokaal
@@ -35,22 +11,14 @@
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
- o.id AS `ID_Organisatie`,
15
+ o.uri AS `ID_Organisatie`,
49
16
  o.name AS `Naam_Organisatie`
50
17
  FROM organizations o
51
18
  JOIN platform pf ON pf.membershipOrganizationId = o.id
52
19
  JOIN registration_periods p ON p.id = o.periodId [[AND p.name = {{scoutsjaar}}]]
53
- GROUP BY o.id, o.name
20
+ WHERE o.active = 1
21
+ GROUP BY o.uri, o.name
54
22
  ORDER BY o.name
55
23
 
56
24
  -- @card deelnemers-bovenlokaal
@@ -59,29 +27,9 @@ 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
- -- The deelnemers of the structure the sheet above delivers: everyone aangesloten at the koepel's own
64
- -- organization in that werkjaar. Being registered there is the engagement that makes someone a
65
- -- structuurvrijwilliger -- nothing in the administration says what a person does within a ploeg -- so
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
30
  -- @include facts
83
31
  SELECT
84
- f.organization_id AS `ID_Organisatie`,
32
+ f.organization_uri AS `ID_Organisatie`,
85
33
  YEAR(f.birth_date) AS `Geboortejaar_deelnemers`,
86
34
  CASE f.`Geslacht` WHEN 'Man' THEN 'M' WHEN 'Vrouw' THEN 'V' ELSE NULL END AS `Gender_deelnemers`,
87
35
  COUNT(DISTINCT f.member_id) AS `Aantal_deelnemers`
@@ -102,28 +50,14 @@ ORDER BY `Geboortejaar_deelnemers`, `Gender_deelnemers`
102
50
  -- size: full
103
51
  -- columns: ID_Organisatie, Naam_Organisatie, Postcode
104
52
  -- 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
53
  SELECT
121
- o.id AS `ID_Organisatie`,
54
+ o.uri AS `ID_Organisatie`,
122
55
  o.name AS `Naam_Organisatie`,
123
56
  CASE WHEN o.postalCode REGEXP '^[0-9]{4}$' THEN CAST(o.postalCode AS UNSIGNED) END AS `Postcode`
124
57
  FROM organizations o
125
58
  JOIN registration_periods p ON p.id = o.periodId [[AND p.name = {{scoutsjaar}}]]
126
- WHERE NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = o.id)
59
+ WHERE o.active = 1
60
+ AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = o.id)
127
61
  GROUP BY `ID_Organisatie`, `Naam_Organisatie`, `Postcode`
128
62
  ORDER BY `Naam_Organisatie`
129
63
 
@@ -134,52 +68,10 @@ ORDER BY `Naam_Organisatie`
134
68
  -- columns: ID_Organisatie, Type_deelnemers, Geboortejaar_deelnemers, Gender_deelnemers, Aantal_deelnemers
135
69
  -- 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 tak en lid in de andere, telt enkel als leiding. Takken zonder categorie leveren niemand: vul die eerst aan.
136
70
  -- 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 tak 'Ondersteunende leden' telt hier mee als leiding. Wie leiding is in de ene tak en lid in de andere, telt enkel als leiding. Takken zonder categorie leveren niemand: vul die eerst aan.
137
- --
138
- -- The deelnemers of the groups the sheet above delivers, split into the two words the template
139
- -- allows: 'leden' and 'leiding', that exact spelling.
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
71
  -- @include facts
180
72
  , inschrijvingen AS (
181
73
  SELECT
182
- f.organization_id,
74
+ f.organization_uri,
183
75
  f.member_id,
184
76
  f.birth_date,
185
77
  f.`Geslacht`,
@@ -189,16 +81,12 @@ ORDER BY `Naam_Organisatie`
189
81
  FROM all_registrations f
190
82
  WHERE
191
83
  -- @include aangesloten
192
- -- The takken of the group and nothing else. A wachtlijst and an activiteit carry no tak, so
193
- -- they already deliver nobody through `type_number` below; said here as well because that is a
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
84
  AND f.group_type = 'Membership'
197
85
  AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = f.organization_id)
198
86
  ),
199
87
  deelnemers AS (
200
88
  SELECT
201
- i.organization_id,
89
+ i.organization_uri,
202
90
  i.member_id,
203
91
  MAX(i.birth_date) AS birth_date,
204
92
  MAX(i.`Geslacht`) AS `Geslacht`,
@@ -207,10 +95,10 @@ deelnemers AS (
207
95
  MAX(i.type_number)
208
96
  ) AS type_number
209
97
  FROM inschrijvingen i
210
- GROUP BY i.organization_id, i.member_id
98
+ GROUP BY i.organization_uri, i.member_id
211
99
  )
212
100
  SELECT
213
- d.organization_id AS `ID_Organisatie`,
101
+ d.organization_uri AS `ID_Organisatie`,
214
102
  CASE WHEN d.type_number = 2 THEN 'leiding' ELSE 'leden' END AS `Type_deelnemers`,
215
103
  YEAR(d.birth_date) AS `Geboortejaar_deelnemers`,
216
104
  CASE d.`Geslacht` WHEN 'Man' THEN 'M' WHEN 'Vrouw' THEN 'V' ELSE NULL END AS `Gender_deelnemers`,
@@ -1,7 +1,7 @@
1
1
  -- @tab nationaal
2
2
  -- title: Nationaal
3
3
  -- description: Ledenaantallen over het hele platform voor het gekozen scoutsjaar.
4
- -- filters: scoutsjaar, aansluiting, ingeschreven_voor
4
+ -- filters: scoutsjaar
5
5
 
6
6
  -- @card aantal-eenheden
7
7
  -- title: Aantal eenheden
@@ -163,18 +163,17 @@ SELECT
163
163
  AS `Type lidgeld`,
164
164
  COUNT(DISTINCT mpm.memberId) AS `Aantal leden`
165
165
  FROM member_platform_memberships mpm
166
- -- Enkel nog om op de aansluiting te kunnen filteren: waar de taart op splitst is het tarief, en dat
167
- -- staat op het lidgeld zelf.
168
- JOIN platform_membership_types mt ON mt.id = mpm.membershipTypeId AND mt.periodId = mpm.periodId
166
+ -- Het lidgeld van een lid in het jaar waarin het lid was, als één join op het paar. Niet als een
167
+ -- IN-subquery per kolom: `leden` wordt dan per subquery opnieuw opgebouwd en MySQL hasht die twee
168
+ -- resultaten tegen elkaar, waarmee de kaart niet meer laadt. Het paar is meteen ook wat de kaart
169
+ -- telt -- een lidgeld uit een jaar waarin dat lid geen lid was, hoort er niet bij.
170
+ JOIN (SELECT DISTINCT member_id, period_id FROM leden) l
171
+ ON l.member_id = mpm.memberId AND l.period_id = mpm.periodId
169
172
  WHERE mpm.deletedAt IS NULL
170
- AND mpm.periodId IN (SELECT DISTINCT period_id FROM leden)
171
- AND mpm.memberId IN (SELECT DISTINCT member_id FROM leden)
172
173
  -- Geen lidmaatschap bij de koepel zelf: `facts` laat die organisatie weg, en wie naast een eenheid
173
174
  -- ook in een nationale ploeg zit zou het tarief daarvan anders in deze grafiek zetten.
174
175
  AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = mpm.organizationId)
175
- -- Alleen de gekozen aansluitingen: `facts` houdt de leden over die er een van hebben, en zonder
176
- -- dit zou de taart daarnaast ook de andere aansluitingen van net die leden tonen.
177
- [[AND mt.name IN ({{aansluiting}})]]
176
+ -- @include ledenstatistieken-aansluitingen
178
177
  GROUP BY mpm.reducedPrice
179
178
  ORDER BY `Aantal leden` DESC
180
179
 
@@ -1,7 +1,7 @@
1
1
  -- @tab netwerk
2
2
  -- title: Netwerk
3
3
  -- description: Leden en eenheden per netwerk voor het gekozen scoutsjaar.
4
- -- filters: scoutsjaar, aansluiting, ingeschreven_voor
4
+ -- filters: scoutsjaar
5
5
  --
6
6
  -- Het netwerk van een eenheid is een tag op de organisatie, bijgehouden per periode: een afgesloten
7
7
  -- jaar houdt het netwerk waarmee het toen geregistreerd stond.
package/report/varia.sql CHANGED
@@ -1,7 +1,7 @@
1
1
  -- @tab varia
2
2
  -- title: Varia
3
3
  -- description: Kinderen en leiding per eenheid, uitgesplitst naar geslacht.
4
- -- filters: scoutsjaar, aansluiting, ingeschreven_voor
4
+ -- filters: scoutsjaar
5
5
 
6
6
  -- @card uldk
7
7
  -- title: ULDK
@@ -1,26 +0,0 @@
1
- -- Which aansluiting a member holds, as the filter above the dashboards asks it: a registration counts
2
- -- when its member holds one of the chosen types in the year that registration is in.
3
- --
4
- -- Nothing chosen drops the whole clause, which is what leaves every member in -- including everyone
5
- -- holding no aansluiting at all. That is the state the dashboards open in.
6
- --
7
- -- `IN` rather than `=`, because several types can be chosen at once: Metabase writes a multi-value
8
- -- filter out as the values it was given, comma separated.
9
- --
10
- -- On the name of the type rather than its id: a type holds a row per year under one id, and the name
11
- -- is what the filter lists, the same way the scoutsjaar and the eenheid are filtered by name.
12
- --
13
- -- Where the aansluiting was recorded is deliberately not part of it. The koepel records one on its
14
- -- own structuurvrijwilligers too, and `all_facts` is read by the sheet that counts exactly those,
15
- -- which an organization condition here would empty.
16
- --
17
- -- Belongs in a WHERE clause that has the registration as `r`.
18
- [[AND EXISTS (
19
- SELECT 1
20
- FROM member_platform_memberships mpm
21
- JOIN platform_membership_types mt ON mt.id = mpm.membershipTypeId AND mt.periodId = mpm.periodId
22
- WHERE mpm.memberId = r.memberId
23
- AND mpm.periodId = r.periodId
24
- AND mpm.deletedAt IS NULL
25
- AND mt.name IN ({{aansluiting}})
26
- )]]
@@ -1,27 +0,0 @@
1
- -- Which registrations are counted, as the filter above the dashboards asks it: a registration stands
2
- -- in a group, and the reader picks which kinds of group say someone is a lid.
3
- --
4
- -- Three names for the three kinds a group can be. A leeftijdsgroep is a tak of the eenheid and is
5
- -- what the ledenstatistieken are read as; an activiteit is a single event someone registered for, and
6
- -- a wachtlijst is a place they are waiting for. The last two are registrations at an eenheid without
7
- -- being a lid of it, which is why the filter opens on leeftijdsgroepen alone and the other two are
8
- -- something a reader asks for.
9
- --
10
- -- Said in those words rather than on `g.type` itself, because the filter is a list a reader picks
11
- -- from and 'EventRegistration' is not a word this report uses anywhere else. A type the CASE does not
12
- -- name falls under no option and drops out until the report says what to call it: a new kind of group
13
- -- is nobody's lid until someone has decided that it is.
14
- --
15
- -- Nothing chosen drops the whole clause and counts every registration, the way the aansluiting filter
16
- -- does. No dashboard opens that way -- the filter starts on Leeftijdsgroepen -- so it is what a
17
- -- reader who empties the filter asked for rather than a state they can land in.
18
- --
19
- -- The years imported from the client's own statistics carry the default of the column, which is what
20
- -- those years are: an export of takken and nothing else.
21
- --
22
- -- Belongs in a WHERE clause that has the group as `g`.
23
- [[AND CASE g.type
24
- WHEN 'Membership' THEN 'Leeftijdsgroepen'
25
- WHEN 'EventRegistration' THEN 'Activiteiten'
26
- WHEN 'WaitingList' THEN 'Wachtlijsten'
27
- END IN ({{ingeschreven_voor}})]]