Skip to content

Commit 91e5ac7

Browse files
committed
feat(fundings): Filter on "region_ignore_funding"
1 parent f7916af commit 91e5ac7

12 files changed

Lines changed: 276 additions & 160 deletions

File tree

client/src/boards/financements-par-aap/charts/classifications/index.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function Classifications({ name }: { name: string | undefined })
7575
field: "participation_is_coordinator",
7676
},
7777
aggregations: {
78-
should_ignore: {
78+
should_ignore_budget: {
7979
terms: {
8080
field: structure ? "participant_ignore_total_budget" : "region_ignore_total_budget",
8181
missing: false,
@@ -116,9 +116,17 @@ export default function Classifications({ name }: { name: string | undefined })
116116
field: "participation_is_coordinator",
117117
},
118118
aggregations: {
119-
sum_budget_participation: {
120-
sum: {
121-
field: "participation_funding",
119+
should_ignore_funding: {
120+
terms: {
121+
field: structure ? "participant_ignore_funding" : "region_ignore_funding",
122+
missing: false,
123+
},
124+
aggregations: {
125+
sum_budget_participation: {
126+
sum: {
127+
field: "participation_funding",
128+
},
129+
},
122130
},
123131
},
124132
},
@@ -144,39 +152,41 @@ export default function Classifications({ name }: { name: string | undefined })
144152
});
145153

146154
const seriesBudget: any = [];
147-
const seriesParticipation: any = [];
155+
const seriesFunding: any = [];
148156
const seriesProject: any = [];
149157
const classificationsBudget = data?.aggregations?.by_classifications_budget?.buckets ?? [];
150-
const classificationsParticipation = data?.aggregations?.by_classifications_participation?.buckets ?? [];
158+
const classificationsFunding = data?.aggregations?.by_classifications_participation?.buckets ?? [];
151159
const classificationsProject = data?.aggregations?.by_classifications_project?.buckets ?? [];
152160
funders.forEach((funder) => {
153161
seriesBudget.push({
154162
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
155163
data: classificationsBudget.map((classification) => classification.by_project_type.buckets
156164
?.find((project) => project.key === funder)?.is_coordinator?.buckets
157-
?.find((bucket) => bucket.key === 1)?.should_ignore?.buckets
165+
?.find((bucket) => bucket.key === 1)?.should_ignore_budget?.buckets
158166
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
159167
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
160168
});
161169
seriesBudget.push({
162170
color: getCssColor({ name: funder, prefix: "funder" }),
163171
data: classificationsBudget.map((classification) => classification.by_project_type.buckets
164172
?.find((project) => project.key === funder)?.is_coordinator?.buckets
165-
?.find((bucket) => bucket.key === 0)?.should_ignore?.buckets
173+
?.find((bucket) => bucket.key === 0)?.should_ignore_budget?.buckets
166174
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
167175
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
168176
});
169-
seriesParticipation.push({
177+
seriesFunding.push({
170178
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
171-
data: classificationsParticipation.map((classification) => classification.by_project_type.buckets
179+
data: classificationsFunding.map((classification) => classification.by_project_type.buckets
172180
?.find((project) => project.key === funder)?.is_coordinator?.buckets
173-
?.find((bucket) => bucket.key === 1)?.sum_budget_participation?.value ?? 0),
181+
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
182+
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
174183
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
175184
});
176-
seriesParticipation.push({
185+
seriesFunding.push({
177186
color: getCssColor({ name: funder, prefix: "funder" }),
178-
data: classificationsParticipation.map((classification) => classification.by_project_type.buckets
187+
data: classificationsFunding.map((classification) => classification.by_project_type.buckets
179188
?.find((project) => project.key === funder)?.is_coordinator?.buckets
189+
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
180190
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
181191
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
182192
});
@@ -197,7 +207,7 @@ export default function Classifications({ name }: { name: string | undefined })
197207
});
198208
const categoriesProject = classificationsProject.map((classification) => classification.key);
199209
const categoriesBudget = classificationsBudget.map((classification) => classification.key);
200-
const categoriesParticipation = classificationsParticipation.map((classification) => classification.key);
210+
const categoriesFunding = classificationsFunding.map((classification) => classification.key);
201211

202212
const title = `Financements par discipline de ${structure ? "l'établissement" : "la région"} ${name} ${getYearRangeLabel({ yearMax, yearMin })}`;
203213
// If view by number of projects
@@ -232,11 +242,11 @@ export default function Classifications({ name }: { name: string | undefined })
232242
// If view by amount by structure
233243
case 'amount_by_structure':
234244
axis = getI18nLabel(i18n, structure ? 'funding_by_structure' : 'funding_by_region');
235-
categories = categoriesParticipation;
245+
categories = categoriesFunding;
236246
dataLabel = function (this: any) {
237247
return `${formatCompactNumber(this.y)} €`;
238248
};
239-
series = seriesParticipation.reverse();
249+
series = seriesFunding.reverse();
240250
stackLabel = function (this: any) {
241251
return `${formatCompactNumber(this.total)} €`;
242252
};

client/src/boards/financements-par-aap/charts/classifications2/index.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function Classifications2({ name }: { name: string | undefined })
7575
field: "participation_is_coordinator",
7676
},
7777
aggregations: {
78-
should_ignore: {
78+
should_ignore_budget: {
7979
terms: {
8080
field: structure ? "participant_ignore_total_budget" : "region_ignore_total_budget",
8181
missing: false,
@@ -116,9 +116,17 @@ export default function Classifications2({ name }: { name: string | undefined })
116116
field: "participation_is_coordinator",
117117
},
118118
aggregations: {
119-
sum_budget_participation: {
120-
sum: {
121-
field: "participation_funding",
119+
should_ignore_funding: {
120+
terms: {
121+
field: structure ? "participant_ignore_funding" : "region_ignore_funding",
122+
missing: false,
123+
},
124+
aggregations: {
125+
sum_budget_participation: {
126+
sum: {
127+
field: "participation_funding",
128+
},
129+
},
122130
},
123131
},
124132
},
@@ -144,41 +152,43 @@ export default function Classifications2({ name }: { name: string | undefined })
144152
});
145153

146154
const seriesBudget: any = [];
147-
const seriesParticipation: any = [];
155+
const seriesFunding: any = [];
148156
const seriesProject: any = [];
149157
const classificationsBudget = data?.aggregations?.by_classifications_budget?.buckets ?? [];
150-
const classificationsParticipation = data?.aggregations?.by_classifications_participation?.buckets ?? [];
158+
const classificationsFunding = data?.aggregations?.by_classifications_participation?.buckets ?? [];
151159
const classificationsProject = data?.aggregations?.by_classifications_project?.buckets ?? [];
152160
classificationsBudget.forEach((classification) => {
153161
seriesBudget.push({
154162
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: classification.key, prefix: "classification" }) } },
155163
data: funders.map((funder) => classification?.by_project_type?.buckets
156164
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
157-
?.find((bucket) => bucket.key === 1)?.should_ignore?.buckets
165+
?.find((bucket) => bucket.key === 1)?.should_ignore_budget?.buckets
158166
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
159167
name: [classification.key, getI18nLabel(i18n, 'coordinator')].join(' - '),
160168
});
161169
seriesBudget.push({
162170
color: getCssColor({ name: classification.key, prefix: "classification" }),
163171
data: funders.map((funder) => classification?.by_project_type?.buckets
164172
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
165-
?.find((bucket) => bucket.key === 0)?.should_ignore?.buckets
173+
?.find((bucket) => bucket.key === 0)?.should_ignore_budget?.buckets
166174
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
167175
name: [classification.key, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
168176
});
169177
});
170-
classificationsParticipation.forEach((classification) => {
171-
seriesParticipation.push({
178+
classificationsFunding.forEach((classification) => {
179+
seriesFunding.push({
172180
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: classification.key, prefix: "classification" }) } },
173181
data: funders.map((funder) => classification?.by_project_type?.buckets
174182
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
175-
?.find((bucket) => bucket.key === 1)?.sum_budget_participation?.value ?? 0),
183+
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
184+
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
176185
name: [classification.key, getI18nLabel(i18n, 'coordinator')].join(' - '),
177186
});
178-
seriesParticipation.push({
187+
seriesFunding.push({
179188
color: getCssColor({ name: classification.key, prefix: "classification" }),
180189
data: funders.map((funder) => classification?.by_project_type?.buckets
181190
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
191+
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
182192
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
183193
name: [classification.key, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
184194
});
@@ -234,7 +244,7 @@ export default function Classifications2({ name }: { name: string | undefined })
234244
dataLabel = function (this: any) {
235245
return `${formatCompactNumber(this.y)} €`;
236246
};
237-
series = seriesParticipation.reverse();
247+
series = seriesFunding.reverse();
238248
stackLabel = function (this: any) {
239249
return `${formatCompactNumber(this.total)} €`;
240250
};

client/src/boards/financements-par-aap/charts/french-partners/index.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
7979
field: "participation_is_coordinator",
8080
},
8181
aggregations: {
82-
should_ignore: {
82+
should_ignore_budget: {
8383
terms: {
8484
field: structure ? "participant_ignore_total_budget" : "region_ignore_total_budget",
8585
missing: false,
@@ -119,9 +119,17 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
119119
field: "participation_is_coordinator",
120120
},
121121
aggregations: {
122-
sum_budget_participation: {
123-
sum: {
124-
field: "participation_funding",
122+
should_ignore_funding: {
123+
terms: {
124+
field: structure ? "participant_ignore_funding" : "region_ignore_funding",
125+
missing: false,
126+
},
127+
aggregations: {
128+
sum_budget_participation: {
129+
sum: {
130+
field: "participation_funding",
131+
},
132+
},
125133
},
126134
},
127135
},
@@ -147,39 +155,41 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
147155
});
148156

149157
const seriesBudget: any = [];
150-
const seriesParticipation: any = [];
158+
const seriesFunding: any = [];
151159
const seriesProject: any = [];
152160
const partnersBudget = data?.aggregations?.by_french_partners_budget?.buckets ?? [];
153-
const partnersParticipation = data?.aggregations?.by_french_partners_participation?.buckets ?? [];
161+
const partnersFunding = data?.aggregations?.by_french_partners_participation?.buckets ?? [];
154162
const partnersProject = data?.aggregations?.by_french_partners_project?.buckets ?? [];
155163
funders.forEach((funder) => {
156164
seriesBudget.push({
157165
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
158166
data: partnersBudget.map((partner) => partner.by_project_type.buckets
159167
?.find((project) => project.key === funder)?.is_coordinator?.buckets
160-
?.find((bucket) => bucket.key === 1)?.should_ignore?.buckets
168+
?.find((bucket) => bucket.key === 1)?.should_ignore_budget?.buckets
161169
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
162170
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
163171
});
164172
seriesBudget.push({
165173
color: getCssColor({ name: funder, prefix: "funder" }),
166174
data: partnersBudget.map((partner) => partner.by_project_type.buckets
167175
?.find((project) => project.key === funder)?.is_coordinator?.buckets
168-
?.find((bucket) => bucket.key === 0)?.should_ignore?.buckets
176+
?.find((bucket) => bucket.key === 0)?.should_ignore_budget?.buckets
169177
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
170178
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
171179
});
172-
seriesParticipation.push({
180+
seriesFunding.push({
173181
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
174-
data: partnersParticipation.map((partner) => partner.by_project_type.buckets
182+
data: partnersFunding.map((partner) => partner.by_project_type.buckets
175183
?.find((project) => project.key === funder)?.is_coordinator?.buckets
176-
?.find((bucket) => bucket.key === 1)?.sum_budget_participation?.value ?? 0),
184+
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
185+
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
177186
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
178187
});
179-
seriesParticipation.push({
188+
seriesFunding.push({
180189
color: getCssColor({ name: funder, prefix: "funder" }),
181-
data: partnersParticipation.map((partner) => partner.by_project_type.buckets
190+
data: partnersFunding.map((partner) => partner.by_project_type.buckets
182191
?.find((project) => project.key === funder)?.is_coordinator?.buckets
192+
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
183193
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
184194
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
185195
});
@@ -206,7 +216,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
206216
const structure = Object.fromEntries(new URLSearchParams(partner.key));
207217
return `${structure.label}`;
208218
});
209-
const categoriesParticipation = partnersParticipation.map((partner) => {
219+
const categoriesFunding = partnersFunding.map((partner) => {
210220
const structure = Object.fromEntries(new URLSearchParams(partner.key));
211221
return `${structure.label}`;
212222
});
@@ -244,11 +254,11 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
244254
// If view by amount by structure
245255
case 'amount_by_structure':
246256
axis = getI18nLabel(i18n, structure ? 'funding_by_structure' : 'funding_by_region');
247-
categories = categoriesParticipation;
257+
categories = categoriesFunding;
248258
dataLabel = function (this: any) {
249259
return `${formatCompactNumber(this.y)} €`;
250260
};
251-
series = seriesParticipation.reverse();
261+
series = seriesFunding.reverse();
252262
stackLabel = function (this: any) {
253263
return `${formatCompactNumber(this.total)} €`;
254264
};

0 commit comments

Comments
 (0)