@stamhoofd/metabase 2.148.0 → 2.150.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -33
- package/dist/api.d.ts +28 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +27 -0
- package/dist/api.js.map +1 -1
- package/dist/report.d.ts +51 -4
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +75 -17
- package/dist/report.js.map +1 -1
- package/dist/sync-report.d.ts +54 -14
- package/dist/sync-report.d.ts.map +1 -1
- package/dist/sync-report.js +87 -15
- package/dist/sync-report.js.map +1 -1
- package/package.json +3 -3
- package/report/eenheden.sql +218 -173
- package/report/filters.sql +11 -41
- package/report/includes/all-non-platform-registrations-all-years.sql +58 -0
- package/report/includes/all-non-platform-registrations.sql +10 -0
- package/report/includes/all-registrations.sql +53 -0
- package/report/includes/child-leader-ratio.sql +4 -0
- package/report/includes/deduplicated-non-platform-registrations-all-years.sql +30 -0
- package/report/includes/deduplicated-non-platform-registrations.sql +30 -0
- package/report/includes/default-age-group-category.sql +2 -0
- package/report/includes/default-age-groups-with-category.sql +10 -0
- package/report/includes/filter-delivery-memberships.sql +2 -0
- package/report/includes/filter-has-delivery-membership.sql +11 -0
- package/report/includes/filter-registration-types.sql +2 -0
- package/report/includes/filter-statistics-memberships.sql +2 -0
- package/report/includes/gtp.sql +10 -48
- package/report/includes/keeo/{tak-categorie.sql → default-age-group-category.sql} +2 -15
- package/report/includes/keeo/filter-delivery-memberships.sql +5 -0
- package/report/includes/keeo/filter-statistics-memberships.sql +5 -0
- package/report/includes/members-per-year.sql +26 -0
- package/report/includes/membership-fee-type.sql +5 -0
- package/report/includes/participant-type.sql +2 -0
- package/report/includes/postal-code-coordinates.sql +2 -0
- package/report/includes/ravot/child-leader-ratio.sql +4 -0
- package/report/includes/ravot/default-age-group-category.sql +15 -0
- package/report/includes/ravot/filter-delivery-memberships.sql +4 -0
- package/report/includes/ravot/filter-statistics-memberships.sql +4 -0
- package/report/includes/ravot/gtp.sql +8 -29
- package/report/includes/ravot/participant-type.sql +7 -0
- package/report/includes/uldk.sql +16 -22
- package/report/includes/years-with-members.sql +11 -0
- package/report/jeugdbewegingen.sql +60 -167
- package/report/nationaal.sql +105 -81
- package/report/netwerk.sql +46 -34
- package/report/varia.sql +11 -9
- package/report/includes/aangesloten.sql +0 -23
- package/report/includes/aansluiting.sql +0 -26
- package/report/includes/facts-alle-jaren.sql +0 -53
- package/report/includes/facts.sql +0 -102
- package/report/includes/ingeschreven-voor.sql +0 -27
- package/report/includes/jaren.sql +0 -20
- package/report/includes/leden-per-jaar.sql +0 -29
- package/report/includes/leden.sql +0 -39
- package/report/includes/omkaderingscijfer.sql +0 -17
- package/report/includes/postcode-coordinaten.sql +0 -8
- package/report/includes/ravot/omkaderingscijfer.sql +0 -25
- package/report/includes/ravot/tak-categorie.sql +0 -28
- package/report/includes/ravot/type-deelnemers.sql +0 -22
- package/report/includes/tak-categorie.sql +0 -18
- package/report/includes/takken.sql +0 -20
- package/report/includes/tarief.sql +0 -14
- package/report/includes/type-deelnemers.sql +0 -14
package/report/filters.sql
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
-- hidden: true
|
|
4
4
|
-- description: Deze vragen vullen de keuzelijsten van de filters bovenaan de dashboards. Ze staan zelf niet op een dashboard.
|
|
5
5
|
--
|
|
6
|
-
-- Elke kaart hier hoort bij een filter met dezelfde naam: de dashboardfilter `
|
|
7
|
-
-- waarden uit de kaart `
|
|
6
|
+
-- Elke kaart hier hoort bij een filter met dezelfde naam: de dashboardfilter `werkjaar` haalt zijn
|
|
7
|
+
-- waarden uit de kaart `werkjaar`.
|
|
8
8
|
|
|
9
|
-
-- @card
|
|
10
|
-
-- title:
|
|
9
|
+
-- @card werkjaar
|
|
10
|
+
-- title: Werkjaren
|
|
11
11
|
-- display: table
|
|
12
12
|
-- size: half
|
|
13
13
|
-- Elke eenheid houdt een eigen periode-rij voor hetzelfde jaar, dus hier staan alle rijen: precies de
|
|
@@ -16,50 +16,20 @@
|
|
|
16
16
|
--
|
|
17
17
|
-- Nieuwste jaar eerst. Metabase sorteert een keuzelijst die uit een vraag komt zelf alfabetisch; de
|
|
18
18
|
-- CLI neemt deze volgorde daarom over in een vaste lijst.
|
|
19
|
-
SELECT name AS `
|
|
19
|
+
SELECT name AS `Werkjaar`
|
|
20
20
|
FROM registration_periods
|
|
21
21
|
GROUP BY name
|
|
22
22
|
ORDER BY MAX(startDate) DESC
|
|
23
23
|
|
|
24
|
-
-- @card aansluiting
|
|
25
|
-
-- title: Aansluitingen
|
|
26
|
-
-- display: table
|
|
27
|
-
-- size: half
|
|
28
|
-
-- Eén rij per type per scoutsjaar, dus gegroepeerd op de naam: de filter zoekt op de naam en een type
|
|
29
|
-
-- zou anders eenmaal per jaar in de lijst staan.
|
|
30
|
-
SELECT name AS `Aansluiting`
|
|
31
|
-
FROM platform_membership_types
|
|
32
|
-
GROUP BY name
|
|
33
|
-
ORDER BY name
|
|
34
|
-
|
|
35
24
|
-- @card eenheid
|
|
36
25
|
-- title: Eenheden
|
|
37
26
|
-- display: table
|
|
38
27
|
-- size: half
|
|
39
28
|
-- Zonder de eigen organisatie van de koepel: de dashboards tellen die nergens mee, dus als filter zou
|
|
40
29
|
-- ze elke kaart op nul zetten.
|
|
41
|
-
SELECT
|
|
42
|
-
FROM organizations
|
|
43
|
-
WHERE
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-- @card ingeschreven-voor
|
|
48
|
-
-- title: Ingeschreven voor
|
|
49
|
-
-- display: table
|
|
50
|
-
-- size: half
|
|
51
|
-
-- De drie soorten inschrijving die `includes/ingeschreven-voor.sql` kent, in de woorden waarin die ze
|
|
52
|
-
-- benoemt. Ze staan in geen enkele tabel: een groep houdt haar soort als 'Membership',
|
|
53
|
-
-- 'EventRegistration' of 'WaitingList' bij, en dat zijn geen woorden die dit rapport ergens toont.
|
|
54
|
-
-- Vandaar hier een vaste lijst, die alleen kan wijzigen als er een soort bijkomt.
|
|
55
|
-
--
|
|
56
|
-
-- Leeftijdsgroepen eerst, want daarop staat de filter standaard; daarna wat een lezer erbij kan
|
|
57
|
-
-- vragen. Metabase sorteert een keuzelijst uit een vraag zelf alfabetisch, dus de CLI neemt deze
|
|
58
|
-
-- volgorde over in een vaste lijst -- en een UNION zonder ORDER BY belooft geen volgorde, vandaar de
|
|
59
|
-
-- kolom waarop gesorteerd wordt.
|
|
60
|
-
SELECT `Ingeschreven voor` FROM (
|
|
61
|
-
SELECT 1 AS volgorde, 'Leeftijdsgroepen' AS `Ingeschreven voor`
|
|
62
|
-
UNION ALL SELECT 2, 'Activiteiten'
|
|
63
|
-
UNION ALL SELECT 3, 'Wachtlijsten'
|
|
64
|
-
) opties
|
|
65
|
-
ORDER BY volgorde
|
|
30
|
+
SELECT organizations.name AS `Eenheid`
|
|
31
|
+
FROM organizations
|
|
32
|
+
WHERE organizations.active = 1
|
|
33
|
+
AND NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = organizations.id)
|
|
34
|
+
GROUP BY organizations.name
|
|
35
|
+
ORDER BY organizations.name
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
-- description: Eén rij per inschrijving over alle werkjaren tegelijk; de eigen organisatie van de koepel telt enkel mee wanneer de dashboardfilter dat vraagt. De jaarfilter bereikt dit fragment niet, wat de trendkaarten lezen.
|
|
2
|
+
WITH default_age_groups_with_category AS (
|
|
3
|
+
-- @include default-age-groups-with-category
|
|
4
|
+
)
|
|
5
|
+
SELECT
|
|
6
|
+
registrations.memberId AS member_id,
|
|
7
|
+
registrations.organizationId AS organization_id,
|
|
8
|
+
organizations.uri AS organization_uri,
|
|
9
|
+
organizations.name AS `Eenheid`,
|
|
10
|
+
organizations.postalCode AS eenheid_postcode,
|
|
11
|
+
organizations.city AS eenheid_gemeente,
|
|
12
|
+
registration_periods.id AS period_id,
|
|
13
|
+
registration_periods.name AS `Werkjaar`,
|
|
14
|
+
registration_periods.startDate AS period_start,
|
|
15
|
+
`groups`.type AS group_type,
|
|
16
|
+
COALESCE(default_age_groups_with_category.name, `groups`.name) AS `Leeftijdsgroep`,
|
|
17
|
+
default_age_groups_with_category.id AS age_group_id,
|
|
18
|
+
default_age_groups_with_category.category AS age_group_category,
|
|
19
|
+
default_age_groups_with_category.minAge AS age_group_min_age,
|
|
20
|
+
default_age_groups_with_category.maxAge AS age_group_max_age,
|
|
21
|
+
COALESCE(
|
|
22
|
+
default_age_groups_with_category.category,
|
|
23
|
+
CASE WHEN default_age_groups_with_category.maxAge < 18 THEN 'child' END,
|
|
24
|
+
CASE WHEN TIMESTAMPDIFF(YEAR, members.birthDate, registration_periods.startDate) < 18 THEN 'child' END
|
|
25
|
+
) AS effective_category,
|
|
26
|
+
CASE members.gender
|
|
27
|
+
WHEN 'Male' THEN 'Man'
|
|
28
|
+
WHEN 'Female' THEN 'Vrouw'
|
|
29
|
+
WHEN 'Other' THEN 'Andere'
|
|
30
|
+
ELSE 'Onbekend'
|
|
31
|
+
END AS `Geslacht`,
|
|
32
|
+
members.birthDate AS birth_date,
|
|
33
|
+
TIMESTAMPDIFF(YEAR, members.birthDate, registration_periods.startDate) AS leeftijd,
|
|
34
|
+
members.postalCode AS postcode,
|
|
35
|
+
registrations.deactivatedAt AS deactivated_at
|
|
36
|
+
FROM registrations
|
|
37
|
+
JOIN registration_periods ON registration_periods.id = registrations.periodId
|
|
38
|
+
JOIN `groups` ON `groups`.id = registrations.groupId AND `groups`.deletedAt IS NULL
|
|
39
|
+
-- The leeftijdsgroep, the member and the eenheid are each recorded per year, so the period is part of what
|
|
40
|
+
-- identifies the row to join to: a leeftijdsgroep that is renamed or a member who moves changes the year it
|
|
41
|
+
-- happened in, not every year they were ever counted in.
|
|
42
|
+
LEFT JOIN default_age_groups_with_category
|
|
43
|
+
ON default_age_groups_with_category.id = `groups`.defaultAgeGroupId
|
|
44
|
+
AND default_age_groups_with_category.periodId = registrations.periodId
|
|
45
|
+
JOIN members ON members.id = registrations.memberId AND members.periodId = registrations.periodId
|
|
46
|
+
JOIN organizations ON organizations.id = registrations.organizationId AND organizations.periodId = registrations.periodId
|
|
47
|
+
AND organizations.active = 1
|
|
48
|
+
WHERE registrations.registeredAt IS NOT NULL
|
|
49
|
+
-- The koepel's own organization only when the dashboard filter asks for it: see
|
|
50
|
+
-- `all-non-platform-registrations.sql`.
|
|
51
|
+
AND (
|
|
52
|
+
{{platformleden_opnemen}}
|
|
53
|
+
OR NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = registrations.organizationId)
|
|
54
|
+
)
|
|
55
|
+
[[AND organizations.name = {{eenheid}}]]
|
|
56
|
+
AND (
|
|
57
|
+
-- @include filter-registration-types
|
|
58
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- description: Eén rij per inschrijving voor het gekozen werkjaar; de eigen organisatie van de koepel telt enkel mee wanneer de dashboardfilter dat vraagt.
|
|
2
|
+
WITH all_registrations AS (
|
|
3
|
+
-- @include all-registrations
|
|
4
|
+
)
|
|
5
|
+
-- The koepel is the national body rather than an eenheid, and the ledenstatistieken normally count
|
|
6
|
+
-- none of its structuurvrijwilligers. `platform.membershipOrganizationId` is the only thing that says
|
|
7
|
+
-- which organization it is; the import writes the koepel under that same id.
|
|
8
|
+
SELECT all_registrations.* FROM all_registrations
|
|
9
|
+
WHERE {{platformleden_opnemen}}
|
|
10
|
+
OR NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = all_registrations.organization_id)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- description: Eén rij per inschrijving, de eigen organisatie van de koepel inbegrepen: wie waar ingeschreven was, in welke leeftijdsgroep, in welk werkjaar.
|
|
2
|
+
WITH default_age_groups_with_category AS (
|
|
3
|
+
-- @include default-age-groups-with-category
|
|
4
|
+
)
|
|
5
|
+
SELECT
|
|
6
|
+
registrations.memberId AS member_id,
|
|
7
|
+
registrations.organizationId AS organization_id,
|
|
8
|
+
organizations.uri AS organization_uri,
|
|
9
|
+
organizations.name AS `Eenheid`,
|
|
10
|
+
organizations.postalCode AS eenheid_postcode,
|
|
11
|
+
organizations.city AS eenheid_gemeente,
|
|
12
|
+
registration_periods.id AS period_id,
|
|
13
|
+
registration_periods.name AS `Werkjaar`,
|
|
14
|
+
registration_periods.startDate AS period_start,
|
|
15
|
+
`groups`.type AS group_type,
|
|
16
|
+
COALESCE(default_age_groups_with_category.name, `groups`.name) AS `Leeftijdsgroep`,
|
|
17
|
+
default_age_groups_with_category.id AS age_group_id,
|
|
18
|
+
default_age_groups_with_category.category AS age_group_category,
|
|
19
|
+
default_age_groups_with_category.minAge AS age_group_min_age,
|
|
20
|
+
default_age_groups_with_category.maxAge AS age_group_max_age,
|
|
21
|
+
COALESCE(
|
|
22
|
+
default_age_groups_with_category.category,
|
|
23
|
+
CASE WHEN default_age_groups_with_category.maxAge < 18 THEN 'child' END,
|
|
24
|
+
CASE WHEN TIMESTAMPDIFF(YEAR, members.birthDate, registration_periods.startDate) < 18 THEN 'child' END
|
|
25
|
+
) AS effective_category,
|
|
26
|
+
CASE members.gender
|
|
27
|
+
WHEN 'Male' THEN 'Man'
|
|
28
|
+
WHEN 'Female' THEN 'Vrouw'
|
|
29
|
+
WHEN 'Other' THEN 'Andere'
|
|
30
|
+
ELSE 'Onbekend'
|
|
31
|
+
END AS `Geslacht`,
|
|
32
|
+
members.birthDate AS birth_date,
|
|
33
|
+
TIMESTAMPDIFF(YEAR, members.birthDate, registration_periods.startDate) AS leeftijd,
|
|
34
|
+
members.postalCode AS postcode,
|
|
35
|
+
registrations.deactivatedAt AS deactivated_at
|
|
36
|
+
FROM registrations
|
|
37
|
+
JOIN registration_periods ON registration_periods.id = registrations.periodId
|
|
38
|
+
JOIN `groups` ON `groups`.id = registrations.groupId AND `groups`.deletedAt IS NULL
|
|
39
|
+
-- The leeftijdsgroep, the member and the eenheid are each recorded per year, so the period is part of what
|
|
40
|
+
-- identifies the row to join to: a leeftijdsgroep that is renamed or a member who moves changes the year it
|
|
41
|
+
-- happened in, not every year they were ever counted in.
|
|
42
|
+
LEFT JOIN default_age_groups_with_category
|
|
43
|
+
ON default_age_groups_with_category.id = `groups`.defaultAgeGroupId
|
|
44
|
+
AND default_age_groups_with_category.periodId = registrations.periodId
|
|
45
|
+
JOIN members ON members.id = registrations.memberId AND members.periodId = registrations.periodId
|
|
46
|
+
JOIN organizations ON organizations.id = registrations.organizationId AND organizations.periodId = registrations.periodId
|
|
47
|
+
AND organizations.active = 1
|
|
48
|
+
WHERE registrations.registeredAt IS NOT NULL
|
|
49
|
+
[[AND registration_periods.name = {{werkjaar}}]]
|
|
50
|
+
[[AND organizations.name = {{eenheid}}]]
|
|
51
|
+
AND (
|
|
52
|
+
-- @include filter-registration-types
|
|
53
|
+
)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- description: Het omkaderingscijfer: voor hoeveel leden een leider gemiddeld dient te zorgen. Aantal kinderen / aantal leiding.
|
|
2
|
+
ROUND(
|
|
3
|
+
COUNT(DISTINCT CASE WHEN age_group_category = 'child' THEN member_id END)
|
|
4
|
+
/ NULLIF(COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- description: Eén rij per lid per eenheid per werkjaar, over alle werkjaren tegelijk: de jaarfilter bereikt dit fragment niet, wat de trendkaarten lezen.
|
|
2
|
+
WITH non_platform_registrations AS (
|
|
3
|
+
-- @include all-non-platform-registrations-all-years
|
|
4
|
+
)
|
|
5
|
+
-- Identical to `deduplicated-non-platform-registrations.sql` apart from the grain it reads; a test keeps the two in step.
|
|
6
|
+
SELECT deduplicated.* FROM (
|
|
7
|
+
SELECT
|
|
8
|
+
non_platform_registrations.*,
|
|
9
|
+
ROW_NUMBER() OVER (
|
|
10
|
+
PARTITION BY non_platform_registrations.organization_id, non_platform_registrations.`Werkjaar`, non_platform_registrations.member_id
|
|
11
|
+
ORDER BY
|
|
12
|
+
(non_platform_registrations.deactivated_at IS NULL) DESC,
|
|
13
|
+
CASE non_platform_registrations.age_group_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
14
|
+
CASE non_platform_registrations.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
15
|
+
non_platform_registrations.age_group_min_age DESC,
|
|
16
|
+
non_platform_registrations.`Leeftijdsgroep`
|
|
17
|
+
) AS rang
|
|
18
|
+
FROM non_platform_registrations
|
|
19
|
+
WHERE EXISTS (
|
|
20
|
+
SELECT 1
|
|
21
|
+
FROM member_platform_memberships
|
|
22
|
+
WHERE member_platform_memberships.memberId = non_platform_registrations.member_id
|
|
23
|
+
AND member_platform_memberships.periodId = non_platform_registrations.period_id
|
|
24
|
+
AND member_platform_memberships.deletedAt IS NULL
|
|
25
|
+
AND (
|
|
26
|
+
-- @include filter-statistics-memberships
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
) deduplicated
|
|
30
|
+
WHERE deduplicated.rang = 1
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- description: Eén rij per lid per eenheid voor het gekozen werkjaar: de inschrijving die voor het lid spreekt. Leiding wint van lid, de oudste leeftijdsgroep wint bij twee.
|
|
2
|
+
WITH non_platform_registrations AS (
|
|
3
|
+
-- @include all-non-platform-registrations
|
|
4
|
+
)
|
|
5
|
+
-- Identical to `deduplicated-non-platform-registrations-all-years.sql` apart from the grain it reads; a test keeps the two in step.
|
|
6
|
+
SELECT deduplicated.* FROM (
|
|
7
|
+
SELECT
|
|
8
|
+
non_platform_registrations.*,
|
|
9
|
+
ROW_NUMBER() OVER (
|
|
10
|
+
PARTITION BY non_platform_registrations.organization_id, non_platform_registrations.`Werkjaar`, non_platform_registrations.member_id
|
|
11
|
+
ORDER BY
|
|
12
|
+
(non_platform_registrations.deactivated_at IS NULL) DESC,
|
|
13
|
+
CASE non_platform_registrations.age_group_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
14
|
+
CASE non_platform_registrations.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
15
|
+
non_platform_registrations.age_group_min_age DESC,
|
|
16
|
+
non_platform_registrations.`Leeftijdsgroep`
|
|
17
|
+
) AS rang
|
|
18
|
+
FROM non_platform_registrations
|
|
19
|
+
WHERE EXISTS (
|
|
20
|
+
SELECT 1
|
|
21
|
+
FROM member_platform_memberships
|
|
22
|
+
WHERE member_platform_memberships.memberId = non_platform_registrations.member_id
|
|
23
|
+
AND member_platform_memberships.periodId = non_platform_registrations.period_id
|
|
24
|
+
AND member_platform_memberships.deletedAt IS NULL
|
|
25
|
+
AND (
|
|
26
|
+
-- @include filter-statistics-memberships
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
) deduplicated
|
|
30
|
+
WHERE deduplicated.rang = 1
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- description: Elke leeftijdsgroep van het platform, met de categorie die zegt wat hij telt als.
|
|
2
|
+
SELECT
|
|
3
|
+
default_age_groups.id,
|
|
4
|
+
default_age_groups.periodId,
|
|
5
|
+
default_age_groups.name,
|
|
6
|
+
default_age_groups.minAge,
|
|
7
|
+
default_age_groups.maxAge,
|
|
8
|
+
-- @include default-age-group-category
|
|
9
|
+
AS category
|
|
10
|
+
FROM default_age_groups
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- description: Of het lid (all_registrations) in dat werkjaar een aansluiting heeft die de aanlevering meetelt.
|
|
2
|
+
EXISTS (
|
|
3
|
+
SELECT 1
|
|
4
|
+
FROM member_platform_memberships
|
|
5
|
+
WHERE member_platform_memberships.memberId = all_registrations.member_id
|
|
6
|
+
AND member_platform_memberships.periodId = all_registrations.period_id
|
|
7
|
+
AND member_platform_memberships.deletedAt IS NULL
|
|
8
|
+
AND (
|
|
9
|
+
-- @include filter-delivery-memberships
|
|
10
|
+
)
|
|
11
|
+
)
|
package/report/includes/gtp.sql
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
3
|
-
-- Bevers / 3 + Eekhoorns / 3 + Welpen / 3 + Wolven + JVG/JG-A + VG/G-J * 2 + Seniors * 3
|
|
4
|
-
-- + leiding - omkaderingscijfer * 2
|
|
5
|
-
--
|
|
6
|
-
-- A unit ideally scores 100 or more. The scale only says something up to roughly 150 members.
|
|
7
|
-
--
|
|
8
|
-
-- Not every platform weighs the index this way: ravot reads the age of a lid rather than the tak, in
|
|
9
|
-
-- `ravot/gtp.sql`, which is what `@include gtp` expands to there.
|
|
10
|
-
--
|
|
11
|
-
-- The takken are matched on `tak_id`, the id of the row in `default_age_groups` a group points at,
|
|
12
|
-
-- which is the same id `keeo/tak-categorie.sql` names them by. Not on the name, which the takken were
|
|
13
|
-
-- weighed by until it turned out to weigh almost nothing: the client's formula spells them as its own
|
|
14
|
-
-- system does -- `Jongverkenners/Jonggidsen - Aspiranten` against the platform's `Jongverkenners,
|
|
15
|
-
-- Jonggidsen, JVG's of Aspiranten` -- and three of the terms matched no tak at all. A name is also
|
|
16
|
-
-- what a tak carries per year, so a rename would drop it out of the index in the year it happened.
|
|
17
|
-
--
|
|
18
|
-
-- A group pointing at no tak has no id and weighs nothing, which is what keeps a group an eenheid
|
|
19
|
-
-- named `Bevers` itself from weighing as the tak it is named after. That makes asking for the category
|
|
20
|
-
-- as well unnecessary: an id is one tak, and `keeo/tak-categorie.sql` is what says that tak is
|
|
21
|
-
-- kinderen.
|
|
22
|
-
--
|
|
23
|
-
-- Eekhoorns and Wolven are not named by the client's formula. Wolven weigh one, like the JVG/JG-A they
|
|
24
|
-
-- sit just below. Eekhoorns weigh a third, with the takken of the same ages, and need no term of their
|
|
25
|
-
-- own: the platform holds one tak for the Bevers and the Zeehonden that an eenheid's Eekhoorns are
|
|
26
|
-
-- registered in, so the first term already counts them.
|
|
27
|
-
--
|
|
28
|
-
-- Reads from `leden`, which holds one row per member per eenheid: the tak a member counts under is
|
|
29
|
-
-- decided there, so nobody is weighed in two terms at once and leiding weigh as leiding only.
|
|
30
|
-
-- Members registered at two eenheden still hold a row each, which is why every term counts distinct
|
|
31
|
-
-- members.
|
|
32
|
-
--
|
|
33
|
-
-- What the years before 2020-2021 weigh rests on the import: the client's export names no tak on the
|
|
34
|
-
-- children of those years, and the import reads one from their age. The few it could not place --
|
|
35
|
-
-- a date of birth that falls outside every tak -- point at no tak and weigh nothing here.
|
|
36
|
-
--
|
|
37
|
-
-- The omkaderingscijfer is the one from `omkaderingscijfer.sql`, unrounded -- only what reaches the
|
|
38
|
-
-- screen is rounded. A unit without leiding has none, and NULLIF keeps the index null there rather
|
|
39
|
-
-- than letting the charts draw a zero.
|
|
1
|
+
-- description: De GTP-index (Gezond Toekomst Perspectief): weegt de leeftijdsgroepen met het oog op potentieel toekomstige leiding. Idealiter scoort een eenheid 100 of meer.
|
|
40
2
|
ROUND(
|
|
41
|
-
( COUNT(DISTINCT CASE WHEN
|
|
42
|
-
+ COUNT(DISTINCT CASE WHEN
|
|
43
|
-
+ COUNT(DISTINCT CASE WHEN
|
|
44
|
-
+ COUNT(DISTINCT CASE WHEN
|
|
45
|
-
+ 2 * COUNT(DISTINCT CASE WHEN
|
|
46
|
-
+ 3 * COUNT(DISTINCT CASE WHEN
|
|
47
|
-
+ COUNT(DISTINCT CASE WHEN
|
|
48
|
-
- 2 * COUNT(DISTINCT CASE WHEN
|
|
49
|
-
/ NULLIF(COUNT(DISTINCT CASE WHEN
|
|
3
|
+
( COUNT(DISTINCT CASE WHEN age_group_id = 'f274a949-9318-4c2b-ae35-e50114efe686' THEN member_id END) -- Bevers of Zeehonden, which an eenheid's Eekhoorns are registered in
|
|
4
|
+
+ COUNT(DISTINCT CASE WHEN age_group_id = '316ea554-675a-493e-a152-365012851ae3' THEN member_id END) ) / 3 -- Welpen
|
|
5
|
+
+ COUNT(DISTINCT CASE WHEN age_group_id = '01d62f7d-c3fa-4314-a33a-21da526a35ff' THEN member_id END) -- Wolven
|
|
6
|
+
+ COUNT(DISTINCT CASE WHEN age_group_id = '57143f32-e4d2-46a7-96e2-9bf82f121e1c' THEN member_id END) -- Jongverkenners, Jonggidsen, JVG's of Aspiranten
|
|
7
|
+
+ 2 * COUNT(DISTINCT CASE WHEN age_group_id = '0eacf56f-3a1d-4e15-bebc-2bc66fc74c7a' THEN member_id END) -- Verkenners, Gidsen, VG's of Juniors
|
|
8
|
+
+ 3 * COUNT(DISTINCT CASE WHEN age_group_id = 'b2275ec6-04ad-4232-bfe3-0eefed97f83b' THEN member_id END) -- Seniors
|
|
9
|
+
+ COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END)
|
|
10
|
+
- 2 * COUNT(DISTINCT CASE WHEN age_group_category = 'child' THEN member_id END)
|
|
11
|
+
/ NULLIF(COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
--
|
|
3
|
-
-- Said here rather than in a hand-filled column of the statistics database, so that the answer lives
|
|
4
|
-
-- with the report instead of in a database nobody can read back: such a column survives no rebuild,
|
|
5
|
-
-- and setting it again means an UPDATE nothing records. Written out in the query, it also stands in
|
|
6
|
-
-- front of whoever opens the question in Metabase, who can correct a tak there and tell us after.
|
|
7
|
-
--
|
|
8
|
-
-- The id rather than the name: a tak holds a row per year, and a rename would silently drop it out of
|
|
9
|
-
-- the list in the year it happened. Ordered as the report divides them.
|
|
10
|
-
--
|
|
11
|
-
-- This is the whole answer, so a tak of keeo that is missing here counts as nothing at all: it is
|
|
12
|
-
-- held by the totals but by none of the three categories, and by no figure that divides leiding from
|
|
13
|
-
-- kinderen. A tak added to the platform configuration has to be added here as well.
|
|
14
|
-
CASE dag.id
|
|
1
|
+
CASE default_age_groups.id
|
|
15
2
|
-- Kinderen
|
|
16
3
|
WHEN 'f274a949-9318-4c2b-ae35-e50114efe686' THEN 'child' -- Bevers of Zeehonden
|
|
17
4
|
WHEN '316ea554-675a-493e-a152-365012851ae3' THEN 'child' -- Welpen
|
|
@@ -27,4 +14,4 @@ CASE dag.id
|
|
|
27
14
|
WHEN 'd4bb14bf-4a52-44e4-a014-3333c5ebb36a' THEN 'adult' -- Nationaal vrijwilligers, rechtstreeks aan FOS
|
|
28
15
|
WHEN '8d42d2df-7787-4959-995d-c5a85d0e48c9' THEN 'adult' -- Ereleden
|
|
29
16
|
WHEN 'ac8848e9-9868-44a1-a057-2a189cce68ea' THEN 'adult' -- Ondersteunende leden, VZW, Steuncomité of Helpende handen
|
|
30
|
-
END
|
|
17
|
+
END
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- description: Wie in welk werkjaar lid was, waar op het platform ook; de eigen organisatie van de koepel volgt de dashboardfilter. Wie naar een andere eenheid verhuist, blijft voor het ledenbehoud meetellen.
|
|
2
|
+
SELECT DISTINCT
|
|
3
|
+
registrations.memberId AS member_id,
|
|
4
|
+
registration_periods.name AS `Werkjaar`
|
|
5
|
+
FROM registrations
|
|
6
|
+
JOIN registration_periods ON registration_periods.id = registrations.periodId
|
|
7
|
+
JOIN `groups` ON `groups`.id = registrations.groupId AND `groups`.deletedAt IS NULL
|
|
8
|
+
WHERE registrations.registeredAt IS NOT NULL
|
|
9
|
+
-- Someone left with only a registration at the koepel is only a blijver when that organization is included.
|
|
10
|
+
AND (
|
|
11
|
+
{{platformleden_opnemen}}
|
|
12
|
+
OR NOT EXISTS (SELECT 1 FROM platform WHERE platform.membershipOrganizationId = registrations.organizationId)
|
|
13
|
+
)
|
|
14
|
+
AND (
|
|
15
|
+
-- @include filter-registration-types
|
|
16
|
+
)
|
|
17
|
+
AND EXISTS (
|
|
18
|
+
SELECT 1
|
|
19
|
+
FROM member_platform_memberships
|
|
20
|
+
WHERE member_platform_memberships.memberId = registrations.memberId
|
|
21
|
+
AND member_platform_memberships.periodId = registrations.periodId
|
|
22
|
+
AND member_platform_memberships.deletedAt IS NULL
|
|
23
|
+
AND (
|
|
24
|
+
-- @include filter-statistics-memberships
|
|
25
|
+
)
|
|
26
|
+
)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- description: Het tarief waaraan een lidgeld (member_platform_memberships) werd aangerekend: het standaardtarief of het verlaagde tarief, onder de naam die het platform eraan geeft.
|
|
2
|
+
CASE WHEN member_platform_memberships.reducedPrice = 1
|
|
3
|
+
THEN COALESCE((SELECT platform.reducedPriceName FROM platform WHERE platform.reducedPriceName IS NOT NULL LIMIT 1), 'Verlaagd tarief')
|
|
4
|
+
ELSE 'Standaardtarief'
|
|
5
|
+
END
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
-- description: Het type deelnemer (van all_registrations) voor de aanlevering: 2 voor leiding, 1 voor leden, 0 voor wie niet meegeteld wordt.
|
|
2
|
+
CASE WHEN all_registrations.age_group_category = 'leader' THEN 2 WHEN all_registrations.age_group_category = 'child' THEN 1 ELSE 0 END
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- description: Het omkaderingscijfer zoals ravot het telt: voor hoeveel leden jonger dan 17 jaar een leider gemiddeld dient te zorgen.
|
|
2
|
+
ROUND(
|
|
3
|
+
COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd < 17 THEN member_id END)
|
|
4
|
+
/ NULLIF(COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- description: Wat elke leeftijdsgroep telt als: child, leader of adult. De ondersteunende leden zijn volwassenen en mogen niet als leiding gecategoriseerd worden: het omkaderingscijfer en de GTP-index zouden hen anders meetellen als leiding die voor de kinderen zorgt.
|
|
2
|
+
CASE default_age_groups.id
|
|
3
|
+
-- Kinderen
|
|
4
|
+
WHEN 'bd63a6ef-d4a1-497d-87a5-d7c36b4ad220' THEN 'child' -- Leeuwkes, Kabouters of Sloebers (6-8)
|
|
5
|
+
WHEN '23607074-624b-472f-926f-c719bb44e314' THEN 'child' -- Springers of Pagadders (8-10)
|
|
6
|
+
WHEN '5730f613-fb72-465b-b902-45b281a0e8b8' THEN 'child' -- Jongknapen, Roodkapjes of Joro's (10-12)
|
|
7
|
+
WHEN '3d56a0b2-9f4b-46ac-998b-d45a9b64cab2' THEN 'child' -- Knapen, Jimmers of Knimmers (12-14)
|
|
8
|
+
WHEN '03680919-689c-4df1-8976-bb71758cc025' THEN 'child' -- Sjo'ers, Simmers of Jonghernieuwers (14-16)
|
|
9
|
+
WHEN 'bed9b513-e0ff-4cc3-a0f3-1c021fc880a9' THEN 'child' -- +16, leiding in spe (16 en ouder)
|
|
10
|
+
WHEN '1ad6b686-d5fa-4168-8fa2-064d49f8c0e8' THEN 'child' -- Hernieuwers
|
|
11
|
+
-- Leiding
|
|
12
|
+
WHEN 'e3ec8d48-0d10-4f5d-9e50-dd3151c6666b' THEN 'leader' -- Leiding
|
|
13
|
+
-- Volwassenen
|
|
14
|
+
WHEN 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 'adult' -- Ondersteunende leden
|
|
15
|
+
END
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
1
|
+
-- description: De GTP-index (Gezond Toekomst Perspectief) zoals ravot ze weegt: op de leeftijd van een lid in plaats van de leeftijdsgroep, met leiding als anderhalf. Idealiter scoort een eenheid 100 of meer.
|
|
3
2
|
-- leden < 10 / 3 + leden 10-13 + leden 14-15 * 2 + leden 16 * 3
|
|
4
3
|
-- + leiding * 1,5 - omkaderingscijfer * 2
|
|
5
|
-
--
|
|
6
|
-
-- The same index as `../gtp.sql` on the same rows, weighed differently: ravot reads the age of a lid
|
|
7
|
-
-- rather than the tak they are in, and counts a leider as one and a half.
|
|
8
|
-
--
|
|
9
|
-
-- A unit ideally scores 100 or more. The scale only says something up to roughly 150 members.
|
|
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 is in none of the buckets the formula names and weighs nothing
|
|
13
|
-
-- there, nor in the omkaderingscijfer it subtracts, and a member whose date of birth is unknown has
|
|
14
|
-
-- no age and falls outside them the same way.
|
|
15
|
-
--
|
|
16
|
-
-- Reads from `leden`, which holds one row per member per eenheid with what they are decided on it:
|
|
17
|
-
-- `tak_category` is the tak they were recorded in rather than their age, so a leider of sixteen
|
|
18
|
-
-- weighs as leiding and not as a kind of sixteen as well, and a kind of a group nobody has
|
|
19
|
-
-- categorised weighs nothing. Members registered at two eenheden still hold a row each, which is why
|
|
20
|
-
-- every term counts distinct members.
|
|
21
|
-
--
|
|
22
|
-
-- The omkaderingscijfer is the one from `omkaderingscijfer.sql` beside this, over the same kinderen
|
|
23
|
-
-- under seventeen, unrounded -- only what reaches the screen is rounded. A unit without leiding has
|
|
24
|
-
-- none, and NULLIF keeps the index null there rather than letting the charts draw a zero.
|
|
25
4
|
ROUND(
|
|
26
|
-
COUNT(DISTINCT CASE WHEN
|
|
27
|
-
+ COUNT(DISTINCT CASE WHEN
|
|
28
|
-
+ 2 * COUNT(DISTINCT CASE WHEN
|
|
29
|
-
+ 3 * COUNT(DISTINCT CASE WHEN
|
|
30
|
-
+ 1.5 * COUNT(DISTINCT CASE WHEN
|
|
31
|
-
- 2 * COUNT(DISTINCT CASE WHEN
|
|
32
|
-
/ NULLIF(COUNT(DISTINCT CASE WHEN
|
|
5
|
+
COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd < 10 THEN member_id END) / 3
|
|
6
|
+
+ COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd BETWEEN 10 AND 13 THEN member_id END)
|
|
7
|
+
+ 2 * COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd BETWEEN 14 AND 15 THEN member_id END)
|
|
8
|
+
+ 3 * COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd = 16 THEN member_id END)
|
|
9
|
+
+ 1.5 * COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END)
|
|
10
|
+
- 2 * COUNT(DISTINCT CASE WHEN age_group_category = 'child' AND leeftijd < 17 THEN member_id END)
|
|
11
|
+
/ NULLIF(COUNT(DISTINCT CASE WHEN age_group_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- description: Het type deelnemer (van all_registrations) voor de aanlevering: 2 voor leiding, 1 voor leden, 0 voor wie niet meegeteld wordt. De ondersteunende leden tellen hier als leiding, want het sjabloon heeft geen derde woord voor hen.
|
|
2
|
+
CASE
|
|
3
|
+
WHEN all_registrations.age_group_category = 'leader' THEN 2
|
|
4
|
+
WHEN all_registrations.age_group_id = 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 2 -- Ondersteunende leden
|
|
5
|
+
WHEN all_registrations.age_group_category = 'child' THEN 1
|
|
6
|
+
ELSE 0
|
|
7
|
+
END
|
package/report/includes/uldk.sql
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
--
|
|
2
|
-
|
|
3
|
-
--
|
|
4
|
-
-- Shared because the totals under the table are the same figures added up. Counted again in a query
|
|
5
|
-
-- of their own they would be a second reading of the same thing, and a total that is not the sum of
|
|
6
|
-
-- the column above it reads as a mistake in either of the two.
|
|
7
|
-
--
|
|
8
|
-
-- Belongs after `leden`.
|
|
9
|
-
, uldk AS (
|
|
10
|
-
SELECT
|
|
11
|
-
`Eenheid` AS `Name`,
|
|
12
|
-
eenheid_gemeente AS `City`,
|
|
13
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Man' THEN member_id END) AS `Aantal kinderen/Man`,
|
|
14
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Vrouw' THEN member_id END) AS `Aantal kinderen/Vrouw`,
|
|
15
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Andere' THEN member_id END) AS `Aantal kinderen/Andere`,
|
|
16
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Onbekend' THEN member_id END) AS `Aantal kinderen/Onbekend`,
|
|
17
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Man' THEN member_id END) AS `Aantal leiding/Man`,
|
|
18
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Vrouw' THEN member_id END) AS `Aantal leiding/Vrouw`,
|
|
19
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Andere' THEN member_id END) AS `Aantal leiding/Andere`,
|
|
20
|
-
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Onbekend' THEN member_id END) AS `Aantal leiding/Onbekend`
|
|
21
|
-
FROM leden
|
|
22
|
-
GROUP BY `Eenheid`, eenheid_gemeente
|
|
1
|
+
-- description: De ULDK-tabel: kinderen en leiding per eenheid, uitgesplitst naar geslacht.
|
|
2
|
+
WITH leden AS (
|
|
3
|
+
-- @include deduplicated-non-platform-registrations
|
|
23
4
|
)
|
|
5
|
+
SELECT
|
|
6
|
+
`Eenheid` AS `Name`,
|
|
7
|
+
eenheid_gemeente AS `City`,
|
|
8
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Man' THEN member_id END) AS `Aantal kinderen/Man`,
|
|
9
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Vrouw' THEN member_id END) AS `Aantal kinderen/Vrouw`,
|
|
10
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Andere' THEN member_id END) AS `Aantal kinderen/Andere`,
|
|
11
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'child' AND `Geslacht` = 'Onbekend' THEN member_id END) AS `Aantal kinderen/Onbekend`,
|
|
12
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Man' THEN member_id END) AS `Aantal leiding/Man`,
|
|
13
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Vrouw' THEN member_id END) AS `Aantal leiding/Vrouw`,
|
|
14
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Andere' THEN member_id END) AS `Aantal leiding/Andere`,
|
|
15
|
+
COUNT(DISTINCT CASE WHEN effective_category = 'leader' AND `Geslacht` = 'Onbekend' THEN member_id END) AS `Aantal leiding/Onbekend`
|
|
16
|
+
FROM leden
|
|
17
|
+
GROUP BY `Eenheid`, eenheid_gemeente
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- description: De werkjaren waarin iemand lid was, elk met het jaar erna ('volgend'): waar het ledenbehoud tegen afgezet wordt.
|
|
2
|
+
WITH leden_per_jaar AS (
|
|
3
|
+
-- @include members-per-year
|
|
4
|
+
)
|
|
5
|
+
-- Grouped by name rather than id, since every eenheid holds its own period row for the same year.
|
|
6
|
+
-- Only the years that have leden: `volgend` would otherwise point at an empty year and read as 0%
|
|
7
|
+
-- ledenbehoud.
|
|
8
|
+
SELECT name, MIN(startDate) AS startDate, LEAD(name) OVER (ORDER BY MIN(startDate)) AS volgend
|
|
9
|
+
FROM registration_periods
|
|
10
|
+
WHERE name IN (SELECT `Werkjaar` FROM leden_per_jaar)
|
|
11
|
+
GROUP BY name
|