@stamhoofd/metabase 2.149.0 → 2.151.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.
Files changed (68) hide show
  1. package/README.md +56 -40
  2. package/dist/api.d.ts +3 -2
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +3 -3
  5. package/dist/api.js.map +1 -1
  6. package/dist/report.d.ts +13 -9
  7. package/dist/report.d.ts.map +1 -1
  8. package/dist/report.js +27 -18
  9. package/dist/report.js.map +1 -1
  10. package/dist/sync-report.d.ts +17 -8
  11. package/dist/sync-report.d.ts.map +1 -1
  12. package/dist/sync-report.js +23 -8
  13. package/dist/sync-report.js.map +1 -1
  14. package/package.json +3 -3
  15. package/report/eenheden.sql +218 -166
  16. package/report/filters.sql +11 -11
  17. package/report/includes/all-non-platform-registrations-all-years.sql +58 -0
  18. package/report/includes/all-non-platform-registrations.sql +7 -0
  19. package/report/includes/all-registrations.sql +53 -0
  20. package/report/includes/child-leader-ratio.sql +4 -0
  21. package/report/includes/deduplicated-non-platform-registrations-all-years.sql +30 -0
  22. package/report/includes/deduplicated-non-platform-registrations.sql +29 -0
  23. package/report/includes/default-age-group-category.sql +2 -0
  24. package/report/includes/default-age-groups-with-category.sql +10 -0
  25. package/report/includes/filter-delivery-memberships.sql +2 -0
  26. package/report/includes/filter-has-delivery-membership.sql +11 -0
  27. package/report/includes/filter-registration-types.sql +2 -0
  28. package/report/includes/filter-statistics-memberships.sql +2 -0
  29. package/report/includes/gtp.sql +10 -48
  30. package/report/includes/keeo/{tak-categorie.sql → default-age-group-category.sql} +2 -15
  31. package/report/includes/keeo/filter-delivery-memberships.sql +5 -0
  32. package/report/includes/keeo/filter-statistics-memberships.sql +5 -0
  33. package/report/includes/members-per-year.sql +26 -0
  34. package/report/includes/membership-fee-type.sql +5 -0
  35. package/report/includes/participant-type.sql +2 -0
  36. package/report/includes/postal-code-coordinates.sql +2 -0
  37. package/report/includes/ravot/child-leader-ratio.sql +4 -0
  38. package/report/includes/ravot/default-age-group-category.sql +15 -0
  39. package/report/includes/ravot/{aanlevering-aansluitingen.sql → filter-delivery-memberships.sql} +1 -1
  40. package/report/includes/ravot/{ledenstatistieken-aansluitingen.sql → filter-statistics-memberships.sql} +1 -2
  41. package/report/includes/ravot/gtp.sql +8 -29
  42. package/report/includes/ravot/participant-type.sql +7 -0
  43. package/report/includes/uldk.sql +16 -22
  44. package/report/includes/years-with-members.sql +11 -0
  45. package/report/jeugdbewegingen.sql +60 -55
  46. package/report/nationaal.sql +101 -76
  47. package/report/netwerk.sql +46 -34
  48. package/report/varia.sql +11 -9
  49. package/report/includes/aangesloten.sql +0 -27
  50. package/report/includes/aanlevering-aansluitingen.sql +0 -1
  51. package/report/includes/facts-alle-jaren.sql +0 -53
  52. package/report/includes/facts.sql +0 -96
  53. package/report/includes/inschrijvingen.sql +0 -2
  54. package/report/includes/jaren.sql +0 -20
  55. package/report/includes/keeo/aanlevering-aansluitingen.sql +0 -5
  56. package/report/includes/keeo/ledenstatistieken-aansluitingen.sql +0 -6
  57. package/report/includes/leden-per-jaar.sql +0 -37
  58. package/report/includes/leden.sql +0 -59
  59. package/report/includes/ledenstatistieken-aansluitingen.sql +0 -1
  60. package/report/includes/omkaderingscijfer.sql +0 -17
  61. package/report/includes/postcode-coordinaten.sql +0 -8
  62. package/report/includes/ravot/omkaderingscijfer.sql +0 -25
  63. package/report/includes/ravot/tak-categorie.sql +0 -28
  64. package/report/includes/ravot/type-deelnemers.sql +0 -22
  65. package/report/includes/tak-categorie.sql +0 -18
  66. package/report/includes/takken.sql +0 -20
  67. package/report/includes/tarief.sql +0 -14
  68. package/report/includes/type-deelnemers.sql +0 -14
@@ -1,53 +0,0 @@
1
- -- The same grain as `facts`, but never filtered by scoutsjaar: the cards that draw a line across the
2
- -- years need every year regardless of which one the dashboard filter has selected. Keep the two in
3
- -- step when changing what counts as an active registration.
4
- WITH
5
- -- @include takken
6
- facts AS (
7
- SELECT
8
- r.memberId AS member_id,
9
- r.organizationId AS organization_id,
10
- o.uri AS organization_uri,
11
- o.name AS `Eenheid`,
12
- o.postalCode AS eenheid_postcode,
13
- o.city AS eenheid_gemeente,
14
- p.id AS period_id,
15
- p.name AS `Scoutsjaar`,
16
- p.startDate AS period_start,
17
- g.type AS group_type,
18
- COALESCE(dag.name, g.name) AS `Tak`,
19
- dag.id AS tak_id,
20
- dag.category AS tak_category,
21
- dag.minAge AS tak_min_age,
22
- dag.maxAge AS tak_max_age,
23
- COALESCE(
24
- dag.category,
25
- CASE WHEN dag.maxAge < 18 THEN 'child' END,
26
- CASE WHEN TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) < 18 THEN 'child' END
27
- ) AS effective_category,
28
- CASE m.gender
29
- WHEN 'Male' THEN 'Man'
30
- WHEN 'Female' THEN 'Vrouw'
31
- WHEN 'Other' THEN 'Andere'
32
- ELSE 'Onbekend'
33
- END AS `Geslacht`,
34
- m.birthDate AS birth_date,
35
- TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) AS leeftijd,
36
- m.postalCode AS postcode,
37
- r.deactivatedAt AS deactivated_at
38
- FROM registrations r
39
- JOIN registration_periods p ON p.id = r.periodId
40
- JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
41
- -- The tak, the member and the eenheid are each recorded per year, so the period is part of what
42
- -- identifies the row to join to: a tak that is renamed or a member who moves changes the year it
43
- -- happened in, not every year they were ever counted in.
44
- LEFT JOIN takken dag ON dag.id = g.defaultAgeGroupId AND dag.periodId = r.periodId
45
- JOIN members m ON m.id = r.memberId AND m.periodId = r.periodId
46
- JOIN organizations o ON o.id = r.organizationId AND o.periodId = r.periodId AND o.active = 1
47
- WHERE r.registeredAt IS NOT NULL
48
- -- Not the koepel's own organization: it is the national body rather than an eenheid, and the
49
- -- ledenstatistieken count none of its structuurvrijwilligers. See `facts.sql`.
50
- AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = r.organizationId)
51
- [[AND o.name = {{eenheid}}]]
52
- -- @include inschrijvingen
53
- )
@@ -1,96 +0,0 @@
1
- -- One row per member per group per scoutsjaar: the grain every figure in the report is counted from.
2
- --
3
- -- The scoutsjaar is the period's name, not its id. A registration points at the period of its own
4
- -- organization, and every organization holds its own row for the same year, so the id identifies a
5
- -- unit's year rather than the year itself. The name is what those rows share, which makes it the
6
- -- only thing a national figure can group on. Imported years are single platform-wide rows and fall
7
- -- out of the same rule.
8
- --
9
- -- A registration counts when it is active: not cancelled and actually registered. A member in two
10
- -- groups appears twice here, so member counts are always COUNT(DISTINCT).
11
- --
12
- -- Which kinds of group count is the reader's, through `ingeschreven-voor.sql`: the ledenstatistieken
13
- -- open on the leeftijdsgroepen alone and can be asked for the activiteiten and the wachtlijsten
14
- -- beside them. `group_type` carries what that filter reads, so a card that may not be asked -- the
15
- -- aanlevering, which is about leden of a jeugdbeweging and about nothing else -- says so itself.
16
- --
17
- -- Two columns say what a registration counts as, and they answer different questions.
18
- -- `tak_category` is what the tak counts as -- kinderen, leiding or volwassenen -- as `takken.sql`
19
- -- decides it, and is null wherever nobody has said. The aanlevering reads that one, and so do the
20
- -- figures that weigh leiding against kinderen: a sheet delivered to a department may not guess, and a
21
- -- division with leiding on one side cannot lean on a fallback that reads every young leider as a
22
- -- kind. `effective_category` is that same answer with the fallbacks the ledenstatistieken need behind
23
- -- it -- the tak's age range, and then the member's own age at the start of the year -- so that nobody
24
- -- drops out of a total for want of a tak that was never categorised.
25
- --
26
- -- That last fallback catches what the import could not name. The client's export leaves the tak empty
27
- -- on the children of the years before 2020-2021; the import reads those from the member's age, except
28
- -- where a date of birth puts them outside every tak. Without the fallback each of those few counts
29
- -- towards the total while showing up in none of the three categories. The handful of adults among
30
- -- them stay null, because nothing here tells leiding from volwassenen.
31
- --
32
- -- Two names for the same rows, the second dropping what the first keeps:
33
- --
34
- -- * `all_registrations` is every registration of the werkjaar, the ones that were cancelled during
35
- -- it included. Someone who stopped in november was a lid of that werkjaar, and both dashboards
36
- -- count them as one: the year is what a figure is about, not the day it is read on.
37
- -- * `facts` is that without the koepel's own organization. Every figure of the ledenstatistieken
38
- -- is counted from it, through `leden.sql`, which narrows it to one row per member.
39
- WITH
40
- -- @include takken
41
- all_registrations AS (
42
- SELECT
43
- r.memberId AS member_id,
44
- r.organizationId AS organization_id,
45
- o.uri AS organization_uri,
46
- o.name AS `Eenheid`,
47
- o.postalCode AS eenheid_postcode,
48
- o.city AS eenheid_gemeente,
49
- p.id AS period_id,
50
- p.name AS `Scoutsjaar`,
51
- p.startDate AS period_start,
52
- g.type AS group_type,
53
- COALESCE(dag.name, g.name) AS `Tak`,
54
- dag.id AS tak_id,
55
- dag.category AS tak_category,
56
- dag.minAge AS tak_min_age,
57
- dag.maxAge AS tak_max_age,
58
- COALESCE(
59
- dag.category,
60
- CASE WHEN dag.maxAge < 18 THEN 'child' END,
61
- CASE WHEN TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) < 18 THEN 'child' END
62
- ) AS effective_category,
63
- CASE m.gender
64
- WHEN 'Male' THEN 'Man'
65
- WHEN 'Female' THEN 'Vrouw'
66
- WHEN 'Other' THEN 'Andere'
67
- ELSE 'Onbekend'
68
- END AS `Geslacht`,
69
- m.birthDate AS birth_date,
70
- TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) AS leeftijd,
71
- m.postalCode AS postcode,
72
- r.deactivatedAt AS deactivated_at
73
- FROM registrations r
74
- JOIN registration_periods p ON p.id = r.periodId
75
- JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
76
- -- The tak, the member and the eenheid are each recorded per year, so the period is part of what
77
- -- identifies the row to join to: a tak that is renamed or a member who moves changes the year it
78
- -- happened in, not every year they were ever counted in.
79
- LEFT JOIN takken dag ON dag.id = g.defaultAgeGroupId AND dag.periodId = r.periodId
80
- JOIN members m ON m.id = r.memberId AND m.periodId = r.periodId
81
- JOIN organizations o ON o.id = r.organizationId AND o.periodId = r.periodId
82
- AND o.active = 1
83
- WHERE r.registeredAt IS NOT NULL
84
- [[AND p.name = {{scoutsjaar}}]]
85
- [[AND o.name = {{eenheid}}]]
86
- -- @include inschrijvingen
87
- ),
88
- -- The koepel's own organization is not an eenheid: it is the national body, and the client's report
89
- -- counts the structuurvrijwilligers of its ploegen as nobody's leden and nobody's leiding. Which
90
- -- organization it is comes from `platform.membershipOrganizationId`, the only thing that says so --
91
- -- the import writes the koepel under that same id, so the years it owns drop out here exactly as the
92
- -- synced ones do.
93
- facts AS (
94
- SELECT f.* FROM all_registrations f
95
- WHERE NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = f.organization_id)
96
- )
@@ -1,2 +0,0 @@
1
- -- Welke soorten inschrijvingen meetellen voor de ledenstatistieken.
2
- AND g.type IN ('Membership', 'EventRegistration')
@@ -1,20 +0,0 @@
1
- -- Elk scoutsjaar met het scoutsjaar erna, waarin het ledenbehoud van dat jaar gemeten wordt. Een
2
- -- scoutsjaar is de naam van de periode: elke eenheid houdt een eigen periode-rij voor hetzelfde jaar,
3
- -- dus alleen de naam is over alle eenheden heen hetzelfde.
4
- --
5
- -- Het ledenbehoud hoort bij het jaar van de leden zelf, niet bij het jaar waarin ze terugkomen: naast
6
- -- scoutsjaar N staat het percentage van de leden van N dat in N+1 nog lid was, zoals het rapport van
7
- -- de klant het ook zet. Het laatste jaar heeft daardoor geen cijfer -- `volgend` is dan NULL -- en
8
- -- moet uit elke kaart gefilterd worden, anders leest het als 0% ledenbehoud.
9
- --
10
- -- Alleen jaren met leden vormen de ketting. Een periode zonder leden -- een jaar dat nog niet
11
- -- gesynchroniseerd is, of een eigen periode van een eenheid -- zou het jaar ervoor anders op 0%
12
- -- ledenbehoud zetten, en het jaar zelf heeft leden nodig om er lid in te kunnen zijn.
13
- --
14
- -- Hoort na `leden-per-jaar`, waar het de jaren met leden uit haalt.
15
- , jaren AS (
16
- SELECT name, MIN(startDate) AS startDate, LEAD(name) OVER (ORDER BY MIN(startDate)) AS volgend
17
- FROM registration_periods
18
- WHERE name IN (SELECT `Scoutsjaar` FROM leden_per_jaar)
19
- GROUP BY name
20
- )
@@ -1,5 +0,0 @@
1
- AND mpm.membershipTypeId IN (
2
- '5d66134e-21b6-41f4-b791-f99779bec8c5', -- Volledig scoutsjaar
3
- 'i-mtype-volledig-scoutsjaar', -- Volledig scoutsjaar, in de geïmporteerde werkjaren
4
- 'f2ffdcb2-5cb3-41ce-be5a-b39bf01570fa' -- Mee op Kamp
5
- )
@@ -1,6 +0,0 @@
1
- -- Welke aansluitingen meetellen als leden voor de ledenstatistieken.
2
- AND mpm.membershipTypeId IN (
3
- '5d66134e-21b6-41f4-b791-f99779bec8c5', -- Volledig scoutsjaar
4
- 'i-mtype-volledig-scoutsjaar', -- Volledig scoutsjaar, in de geïmporteerde werkjaren
5
- 'f2ffdcb2-5cb3-41ce-be5a-b39bf01570fa' -- Mee op Kamp
6
- )
@@ -1,37 +0,0 @@
1
- -- Wie in welk scoutsjaar lid was, over het hele platform en zonder filters op wie meetelt.
2
- --
3
- -- Dit is de "is nog lid"-kant van het ledenbehoud. Een lid dat het jaar erna bij een andere eenheid
4
- -- opduikt telt als blijver: zo rekent het rapport van de klant het ook. De cijfers van 9e Wandelaar
5
- -- tonen het verschil — 38, 54 en 46 blijvers met deze telling, 37, 51 en 45 als alleen dezelfde
6
- -- eenheid meetelt.
7
- --
8
- -- Bewust niet uit `facts` gehaald: die is gefilterd op de gekozen eenheid, en dan zou een lid dat
9
- -- verhuist juist wel als vertrekker tellen.
10
- --
11
- -- Op wat lid zijn is na. Waar iemand lid is doet er niet toe, wat voor inschrijving het is en
12
- -- waarvoor die aangesloten is wel: telt de noemer enkel wie aangesloten is en de teller elke
13
- -- inschrijving, dan is wie vertrokken is maar het jaar erna één activiteit meedoet een blijver.
14
- -- Dezelfde twee regels staan daarom aan beide kanten van de breuk, zodat "is nog lid" hetzelfde
15
- -- betekent als "was lid".
16
- , leden_per_jaar AS (
17
- SELECT DISTINCT
18
- r.memberId AS member_id,
19
- p.name AS `Scoutsjaar`
20
- FROM registrations r
21
- JOIN registration_periods p ON p.id = r.periodId
22
- JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
23
- WHERE r.registeredAt IS NOT NULL
24
- -- Wie het jaar erna alleen nog bij de koepel zelf ingeschreven staat is geen blijver: dat is
25
- -- dezelfde organisatie die `facts` weglaat, en een cijfer dat hier wel meetelt en daar niet zou
26
- -- een ledenbehoud boven de leden zetten waar het over gaat.
27
- AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = r.organizationId)
28
- -- @include inschrijvingen
29
- AND EXISTS (
30
- SELECT 1
31
- FROM member_platform_memberships mpm
32
- WHERE mpm.memberId = r.memberId
33
- AND mpm.periodId = r.periodId
34
- AND mpm.deletedAt IS NULL
35
- -- @include ledenstatistieken-aansluitingen
36
- )
37
- )
@@ -1,59 +0,0 @@
1
- -- One row per member per eenheid per scoutsjaar: what someone is, decided once, before the figures
2
- -- that weigh leiding against kinderen count them.
3
- --
4
- -- `facts` holds a row per registration, so a member registered in two takken of the same eenheid
5
- -- stands in it twice. Counted as they stand there, someone who is leiding in one tak and lid in
6
- -- another is counted as both -- in the omkaderingscijfer as a kind and as the leider they are
7
- -- divided by at once -- and the GTP index weighs such a member in two of its terms. This picks the
8
- -- one registration that says what they are, the way `jeugdbewegingen.sql` picks it for the
9
- -- aanlevering: a registration that still stands beats one that was cancelled, leiding beats lid, and
10
- -- between two takken the oldest one wins, since that is the one a member has grown into. The name of
11
- -- the tak breaks a tie no age can, so that two runs of the same query cannot pick differently.
12
- --
13
- -- A cancelled registration says someone was there, not what they were, which is why it sorts last:
14
- -- a lid put in Leiding by mistake and taken out again would otherwise be leiding for the rest of the
15
- -- werkjaar, while the registration they really hold says what they are.
16
- --
17
- -- What a member is comes from `tak_category`, what the tak was recorded as, and never from
18
- -- `effective_category`, which falls back to the member's own age. That fallback cannot tell leiding
19
- -- from anything, so a leider of sixteen would read as a kind and be counted on both sides of the same
20
- -- division. It does decide between two rows that the takken leave equally unsaid, so that a member
21
- -- whose only reading is the fallback keeps it rather than losing it to whichever row sorted first.
22
- --
23
- -- Every member keeps a row, whether their tak is categorised or not, and every row keeps both
24
- -- columns: a card that counts kinderen the way the totals do goes on reading `effective_category`
25
- -- here, and only counts a member once now.
26
- --
27
- -- Where the aansluitingen the report counts a lid under are applied, in
28
- -- `ledenstatistieken-aansluitingen.sql`. Here rather than in either grain, because the aanlevering
29
- -- reads a grain and never this: the two dashboards say for themselves what they count a lid as.
30
- --
31
- -- Before the ranking, not after: a registration that is not aangesloten may not be the one that
32
- -- speaks for a member, or someone would be dropped over the very row that does not count.
33
- --
34
- -- Belongs after `facts` or `facts-alle-jaren`, whichever grain the card reads.
35
- , leden AS (
36
- SELECT g.* FROM (
37
- SELECT
38
- f.*,
39
- ROW_NUMBER() OVER (
40
- PARTITION BY f.organization_id, f.`Scoutsjaar`, f.member_id
41
- ORDER BY
42
- (f.deactivated_at IS NULL) DESC,
43
- CASE f.tak_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
44
- CASE f.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
45
- f.tak_min_age DESC,
46
- f.`Tak`
47
- ) AS rang
48
- FROM facts f
49
- WHERE EXISTS (
50
- SELECT 1
51
- FROM member_platform_memberships mpm
52
- WHERE mpm.memberId = f.member_id
53
- AND mpm.periodId = f.period_id
54
- AND mpm.deletedAt IS NULL
55
- -- @include ledenstatistieken-aansluitingen
56
- )
57
- ) g
58
- WHERE g.rang = 1
59
- )
@@ -1 +0,0 @@
1
- -- Welke aansluitingen meetellen als leden voor de ledenstatistieken.
@@ -1,17 +0,0 @@
1
- -- The omkaderingscijfer: how many children a leider looks after on average.
2
- --
3
- -- Aantal kinderen / Aantal leiding
4
- --
5
- -- Low is good, and from 10 upwards keeping an eye on everyone gets hard. Also the divisor of the GTP
6
- -- index, which takes it from here unrounded -- only what reaches the screen is rounded here.
7
- --
8
- -- Counts the kinderen and the leiding of a categorised tak, so that nobody stands on both sides of
9
- -- the division: someone who is leiding in one tak and lid in another is a leider here and not also
10
- -- one of the children they look after. A member whose tak nobody has categorised is neither, and is
11
- -- counted by the totals beside this rather than by the division -- which is why `Aantal kinderen`
12
- -- divided by `Aantal leiding` off the same page can come out slightly higher.
13
- --
14
- -- Reads from `leden`, one row per member per eenheid, where that is decided.
15
- ROUND(
16
- COUNT(DISTINCT CASE WHEN tak_category = 'child' THEN member_id END)
17
- / NULLIF(COUNT(DISTINCT CASE WHEN tak_category = 'leader' THEN member_id END), 0), 2)
@@ -1,8 +0,0 @@
1
- -- Where a postal code is, so Metabase can put a point on the map for it.
2
- --
3
- -- The maps attach this with a LEFT JOIN, because what members have in their postal code field is not
4
- -- always a Belgian postal code: typos, a Dutch one, or a whole address typed into the box. Those
5
- -- members keep counting towards the totals, they just get no pin. An INNER JOIN would drop them.
6
- , postcode_coordinaten AS (
7
- SELECT postalCode, latitude, longitude FROM postal_codes
8
- )
@@ -1,25 +0,0 @@
1
- -- The omkaderingscijfer as ravot counts it: how many kinderen a leider looks after on average.
2
- --
3
- -- Aantal kinderen jonger dan 17 / Aantal leiding
4
- --
5
- -- The same figure as `../omkaderingscijfer.sql` on the same rows, over fewer kinderen: ravot reads
6
- -- the age of a lid rather than the tak they are in, here as in `gtp.sql` beside it, and counts only
7
- -- the kinderen that index weighs. Low is good, and from 10 upwards keeping an eye on everyone gets
8
- -- hard. Also the divisor of the GTP index, which takes it from here unrounded -- only what reaches
9
- -- the screen is rounded here.
10
- --
11
- -- `leeftijd` is the age at the start of the werkjaar, the age the rest of the report charts members
12
- -- by. A kind of seventeen or older weighs in no term of the index and is outside this division too,
13
- -- and a member whose date of birth is unknown has no age and falls outside it the same way.
14
- --
15
- -- Counts the kinderen and the leiding of a categorised tak, so that nobody stands on both sides of
16
- -- the division: someone who is leiding in one tak and lid in another is a leider here and not also
17
- -- one of the children they look after. A member whose tak nobody has categorised is neither, and is
18
- -- counted by the totals beside this rather than by the division -- which is why `Aantal kinderen`
19
- -- divided by `Aantal leiding` off the same page comes out higher: those totals count a kind by the
20
- -- category of their tak, so they hold the kinderen of seventeen and over as well.
21
- --
22
- -- Reads from `leden`, one row per member per eenheid, where that is decided.
23
- ROUND(
24
- COUNT(DISTINCT CASE WHEN tak_category = 'child' AND leeftijd < 17 THEN member_id END)
25
- / NULLIF(COUNT(DISTINCT CASE WHEN tak_category = 'leader' THEN member_id END), 0), 2)
@@ -1,28 +0,0 @@
1
- -- The takken of ravot, by the id they carry in the platform configuration.
2
- --
3
- -- Said here rather than in a hand-filled column of the statistics database, for the reasons
4
- -- `../tak-categorie.sql` gives. This is the whole answer, so a tak of ravot that is missing here
5
- -- counts as nothing at all, and a tak added to the platform configuration has to be added here too.
6
- --
7
- -- The ondersteunende leden are volwassenen and may not be categorised as leiding: the
8
- -- omkaderingscijfer and the GTP index would then read them as leiding that the kinderen of an eenheid
9
- -- are looked after by. The aanlevering, which does deliver them among the leiding because the
10
- -- department has no third word for them, names the tak itself instead -- see `type-deelnemers.sql`.
11
- --
12
- -- The two oldest takken of kinderen carry members of seventeen and over, which is what
13
- -- `omkaderingscijfer.sql` means when it says the totals beside it hold those as well. They weigh in
14
- -- no term of the GTP index, which stops at sixteen.
15
- CASE dag.id
16
- -- Kinderen
17
- WHEN 'bd63a6ef-d4a1-497d-87a5-d7c36b4ad220' THEN 'child' -- Leeuwkes, Kabouters of Sloebers (6-8)
18
- WHEN '23607074-624b-472f-926f-c719bb44e314' THEN 'child' -- Springers of Pagadders (8-10)
19
- WHEN '5730f613-fb72-465b-b902-45b281a0e8b8' THEN 'child' -- Jongknapen, Roodkapjes of Joro's (10-12)
20
- WHEN '3d56a0b2-9f4b-46ac-998b-d45a9b64cab2' THEN 'child' -- Knapen, Jimmers of Knimmers (12-14)
21
- WHEN '03680919-689c-4df1-8976-bb71758cc025' THEN 'child' -- Sjo'ers, Simmers of Jonghernieuwers (14-16)
22
- WHEN 'bed9b513-e0ff-4cc3-a0f3-1c021fc880a9' THEN 'child' -- +16, leiding in spe (16 en ouder)
23
- WHEN '1ad6b686-d5fa-4168-8fa2-064d49f8c0e8' THEN 'child' -- Hernieuwers
24
- -- Leiding
25
- WHEN 'e3ec8d48-0d10-4f5d-9e50-dd3151c6666b' THEN 'leader' -- Leiding
26
- -- Volwassenen
27
- WHEN 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 'adult' -- Ondersteunende leden
28
- END AS category
@@ -1,22 +0,0 @@
1
- -- What a deelnemer of a lokale groep is delivered as, as ravot counts it: the same as
2
- -- `../type-deelnemers.sql` with the ondersteunende leden among the leiding.
3
- --
4
- -- Ondersteunende leden are volwassenen who carry a group rather than a tak of kinderen, and the
5
- -- metadatafiche counts the volwassen begeleiders, kassabeheerders and secretarissen of a group as
6
- -- leiding -- the department has no third word for them. The tak is not categorised as leiding, and
7
- -- may not be: the omkaderingscijfer and the GTP index would then read it as leiding the kinderen of
8
- -- an eenheid are looked after by. The aanlevering therefore names the tak itself.
9
- --
10
- -- Named by `tak_id`, the id of the row in `default_age_groups`, the way `gtp.sql` weighs the takken
11
- -- it names: a name is what a tak carries per year, so a rename would stop delivering it in the year
12
- -- it happened. The id is the one `tak-categorie.sql` beside this names it by.
13
- --
14
- -- A group an eenheid named `Ondersteunende leden` itself points at no tak, so it carries no id and is
15
- -- delivered as neither. Under the name it was matched by before, such a group was delivered as
16
- -- leiding.
17
- CASE
18
- WHEN f.tak_category = 'leader' THEN 2
19
- WHEN f.tak_id = 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 2 -- Ondersteunende leden
20
- WHEN f.tak_category = 'child' THEN 1
21
- ELSE 0
22
- END
@@ -1,18 +0,0 @@
1
- -- What a tak counts as -- kinderen, leiding or volwassenen -- for the platform reading the report.
2
- --
3
- -- Nothing in the administration knows it. The platform configuration has no such field, and the ages
4
- -- do not answer it, since leiding and stam carry no age range and a tak of kinderen need not carry
5
- -- one either. The statistics database does not hold it either: it kept a hand-filled `category`
6
- -- column on `default_age_groups` until the reports began naming their takken themselves, and that
7
- -- column is dropped.
8
- --
9
- -- So a platform says which of its takken are which here, in `includes/<env>/tak-categorie.sql`, which
10
- -- is what `@include tak-categorie` expands to there. This unqualified one is what a platform that has
11
- -- not is left with: nothing. That is not a failure -- the reports count a tak nobody has categorised
12
- -- separately rather than guessing at it, and `effective_category` still reads the ages behind it so
13
- -- that no kind drops out of a total -- but every figure dividing leiding from kinderen stays empty
14
- -- until the list is written.
15
- --
16
- -- Belongs in the select list of the `takken` fragment, which has the row of `default_age_groups` as
17
- -- `dag`. It is the column the rest of the report reads as `dag.category`.
18
- CAST(NULL AS CHAR(16)) AS category
@@ -1,20 +0,0 @@
1
- -- The takken every organization's groups map onto, as the report reads them: the rows of
2
- -- `default_age_groups` with their category decided.
3
- --
4
- -- A fragment of its own because both grains of `facts` join it, and because it is where the one thing
5
- -- about a tak that is neither synced nor derivable is settled -- see `tak-categorie.sql`. `category`
6
- -- is no column of `default_age_groups`: it is added here, which is why the takken are read through
7
- -- this rather than joined straight from the table. Everything downstream reads it as `dag`, so a
8
- -- tak's name, ages and category are asked for the same way.
9
- --
10
- -- Belongs at the head of a `WITH`, and carries the comma to whatever CTE follows it.
11
- takken AS (
12
- SELECT
13
- dag.id,
14
- dag.periodId,
15
- dag.name,
16
- dag.minAge,
17
- dag.maxAge,
18
- -- @include tak-categorie
19
- FROM default_age_groups dag
20
- ),
@@ -1,14 +0,0 @@
1
- -- Het tarief waaraan een lidgeld is aangerekend: het standaardtarief, of het verlaagde tarief van de
2
- -- koepel. Dat is wat de rapporten "type lidgeld" noemen -- de aansluiting zegt waarvoor iemand is
3
- -- aangesloten, dit zegt wat ervoor betaald werd.
4
- --
5
- -- De naam van het verlaagde tarief is die van de koepel zelf (SOMkort, kansentarief). Ze staat op de
6
- -- platformrij, want alleen het platform zelf weet hoe het dat tarief noemt. Er is één zo'n rij, dus
7
- -- de subquery levert één naam; een platform dat er geen naam aan geeft valt terug op de bewoording
8
- -- hier, en een databank waarin nog niets gesynchroniseerd is ook.
9
- --
10
- -- Hoort bij een query die de lidgelden als `mpm` heeft.
11
- CASE WHEN mpm.reducedPrice = 1
12
- THEN COALESCE((SELECT pf.reducedPriceName FROM platform pf WHERE pf.reducedPriceName IS NOT NULL LIMIT 1), 'Verlaagd tarief')
13
- ELSE 'Standaardtarief'
14
- END
@@ -1,14 +0,0 @@
1
- -- What a deelnemer of a lokale groep is delivered as on the aanlevering: leiding, leden, or neither.
2
- --
3
- -- Read from `tak_category`, what the takken were recorded as, on a registration of
4
- -- `all_registrations` as `f`. Only the two words the template allows are delivered: a tak recorded as
5
- -- volwassenen is neither, and a tak nobody has categorised delivers nobody rather than being guessed
6
- -- at.
7
- --
8
- -- The numbers rank rather than label -- leiding beats leden, and leden beats a tak that is neither --
9
- -- so the MAX over a member's registrations picks the strongest thing any of them says.
10
- --
11
- -- Not every platform delivers the same people as leiding: ravot counts its ondersteunende leden
12
- -- among them, in `ravot/type-deelnemers.sql`, which is what `@include type-deelnemers` expands to
13
- -- there.
14
- CASE WHEN f.tak_category = 'leader' THEN 2 WHEN f.tak_category = 'child' THEN 1 ELSE 0 END