Skip to content

Commit 8249cc1

Browse files
committed
feat(fundings): Remove "coordinators" for graphs about regions
1 parent 8b7be10 commit 8249cc1

17 files changed

Lines changed: 424 additions & 136 deletions

File tree

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

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ export default function Classifications({ name }: { name: string | undefined })
9494
},
9595
},
9696
},
97-
by_classifications_participation: {
97+
by_classifications_funding: {
9898
terms: {
9999
field: "project_classification.primary_field.keyword",
100-
order: { "sum_budget_participation": "desc" },
100+
order: { "sum_budget_funding": "desc" },
101101
size: 15,
102102
},
103103
aggregations: {
104-
sum_budget_participation: {
104+
sum_budget_funding: {
105105
sum: {
106106
field: "participation_funding",
107107
},
@@ -122,7 +122,7 @@ export default function Classifications({ name }: { name: string | undefined })
122122
missing: false,
123123
},
124124
aggregations: {
125-
sum_budget_participation: {
125+
sum_budget_funding: {
126126
sum: {
127127
field: "participation_funding",
128128
},
@@ -154,8 +154,11 @@ export default function Classifications({ name }: { name: string | undefined })
154154
const seriesBudget: any = [];
155155
const seriesFunding: any = [];
156156
const seriesProject: any = [];
157+
const seriesBudgetRegion: any = [];
158+
const seriesFundingRegion: any = [];
159+
const seriesProjectRegion: any = [];
157160
const classificationsBudget = data?.aggregations?.by_classifications_budget?.buckets ?? [];
158-
const classificationsFunding = data?.aggregations?.by_classifications_participation?.buckets ?? [];
161+
const classificationsFunding = data?.aggregations?.by_classifications_funding?.buckets ?? [];
159162
const classificationsProject = data?.aggregations?.by_classifications_project?.buckets ?? [];
160163
funders.forEach((funder) => {
161164
seriesBudget.push({
@@ -174,22 +177,38 @@ export default function Classifications({ name }: { name: string | undefined })
174177
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
175178
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
176179
});
180+
seriesBudgetRegion.push({
181+
color: getCssColor({ name: funder, prefix: "funder" }),
182+
data: classificationsBudget.map((classification) => classification
183+
?.by_project_type.buckets?.find((project) => project.key === funder)
184+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_budget?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget?.value ?? 0), 0)
185+
?? 0),
186+
name: funder,
187+
});
177188
seriesFunding.push({
178189
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
179190
data: classificationsFunding.map((classification) => classification.by_project_type.buckets
180191
?.find((project) => project.key === funder)?.is_coordinator?.buckets
181192
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
182-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
193+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
183194
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
184195
});
185196
seriesFunding.push({
186197
color: getCssColor({ name: funder, prefix: "funder" }),
187198
data: classificationsFunding.map((classification) => classification.by_project_type.buckets
188199
?.find((project) => project.key === funder)?.is_coordinator?.buckets
189200
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
190-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
201+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
191202
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
192203
});
204+
seriesFundingRegion.push({
205+
color: getCssColor({ name: funder, prefix: "funder" }),
206+
data: classificationsFunding.map((classification) => classification
207+
?.by_project_type.buckets?.find((project) => project.key === funder)
208+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_funding?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget_funding?.value ?? 0), 0)
209+
?? 0),
210+
name: funder,
211+
});
193212
seriesProject.push({
194213
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
195214
data: classificationsProject.map((classification) => classification.by_project_type.buckets
@@ -204,6 +223,14 @@ export default function Classifications({ name }: { name: string | undefined })
204223
?.find((bucket) => bucket.key === 0)?.unique_projects?.value ?? 0),
205224
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
206225
});
226+
seriesProjectRegion.push({
227+
color: getCssColor({ name: funder, prefix: "funder" }),
228+
data: classificationsProject.map((classification) => classification
229+
?.by_project_type.buckets?.find((project) => project.key === funder)
230+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.unique_projects?.value ?? 0), 0)
231+
?? 0),
232+
name: funder,
233+
});
207234
});
208235
const categoriesProject = classificationsProject.map((classification) => classification.key);
209236
const categoriesBudget = classificationsBudget.map((classification) => classification.key);
@@ -216,7 +243,7 @@ export default function Classifications({ name }: { name: string | undefined })
216243
let dataLabel = function (this: any) {
217244
return `${this.y} projet${this.y > 1 ? 's' : ''}`;
218245
};
219-
let series = seriesProject.reverse();
246+
let series = structure ? seriesProject.reverse() : seriesProjectRegion.reverse();
220247
let stackLabel = function (this: any) {
221248
return `${this.total} projet${this.total > 1 ? 's' : ''}`;
222249
};
@@ -231,7 +258,7 @@ export default function Classifications({ name }: { name: string | undefined })
231258
dataLabel = function (this: any) {
232259
return `${formatCompactNumber(this.y)} €`;
233260
};
234-
series = seriesBudget.reverse();
261+
series = structure ? seriesBudget.reverse() : seriesBudgetRegion.reverse();
235262
stackLabel = function (this: any) {
236263
return `${formatCompactNumber(this.total)} €`;
237264
};
@@ -246,7 +273,7 @@ export default function Classifications({ name }: { name: string | undefined })
246273
dataLabel = function (this: any) {
247274
return `${formatCompactNumber(this.y)} €`;
248275
};
249-
series = seriesFunding.reverse();
276+
series = structure ? seriesFunding.reverse() : seriesFundingRegion.reverse();
250277
stackLabel = function (this: any) {
251278
return `${formatCompactNumber(this.total)} €`;
252279
};

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ export default function Classifications2({ name }: { name: string | undefined })
9797
by_classifications_participation: {
9898
terms: {
9999
field: "project_classification.primary_field.keyword",
100-
order: { "sum_budget_participation": "desc" },
100+
order: { "sum_budget_funding": "desc" },
101101
size: 15,
102102
},
103103
aggregations: {
104-
sum_budget_participation: {
104+
sum_budget_funding: {
105105
sum: {
106106
field: "participation_funding",
107107
},
@@ -122,7 +122,7 @@ export default function Classifications2({ name }: { name: string | undefined })
122122
missing: false,
123123
},
124124
aggregations: {
125-
sum_budget_participation: {
125+
sum_budget_funding: {
126126
sum: {
127127
field: "participation_funding",
128128
},
@@ -154,6 +154,9 @@ export default function Classifications2({ name }: { name: string | undefined })
154154
const seriesBudget: any = [];
155155
const seriesFunding: any = [];
156156
const seriesProject: any = [];
157+
const seriesBudgetRegion: any = [];
158+
const seriesFundingRegion: any = [];
159+
const seriesProjectRegion: any = [];
157160
const classificationsBudget = data?.aggregations?.by_classifications_budget?.buckets ?? [];
158161
const classificationsFunding = data?.aggregations?.by_classifications_participation?.buckets ?? [];
159162
const classificationsProject = data?.aggregations?.by_classifications_project?.buckets ?? [];
@@ -174,24 +177,40 @@ export default function Classifications2({ name }: { name: string | undefined })
174177
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
175178
name: [classification.key, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
176179
});
180+
seriesBudgetRegion.push({
181+
color: getCssColor({ name: classification.key, prefix: "classification" }),
182+
data: funders.map((funder) => classification
183+
?.by_project_type.buckets?.find((project) => project.key === funder)
184+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_budget?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget?.value ?? 0), 0)
185+
?? 0),
186+
name: classification.key,
187+
});
177188
});
178189
classificationsFunding.forEach((classification) => {
179190
seriesFunding.push({
180191
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: classification.key, prefix: "classification" }) } },
181192
data: funders.map((funder) => classification?.by_project_type?.buckets
182193
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
183194
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
184-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
195+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
185196
name: [classification.key, getI18nLabel(i18n, 'coordinator')].join(' - '),
186197
});
187198
seriesFunding.push({
188199
color: getCssColor({ name: classification.key, prefix: "classification" }),
189200
data: funders.map((funder) => classification?.by_project_type?.buckets
190201
?.find((bucket) => bucket.key === funder)?.is_coordinator?.buckets
191202
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
192-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
203+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
193204
name: [classification.key, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
194205
});
206+
seriesFundingRegion.push({
207+
color: getCssColor({ name: classification.key, prefix: "classification" }),
208+
data: funders.map((funder) => classification
209+
?.by_project_type.buckets?.find((project) => project.key === funder)
210+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_funding?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget_funding?.value ?? 0), 0)
211+
?? 0),
212+
name: classification.key,
213+
});
195214
});
196215
classificationsProject.forEach((classification) => {
197216
seriesProject.push({
@@ -208,6 +227,14 @@ export default function Classifications2({ name }: { name: string | undefined })
208227
?.find((bucket) => bucket.key === 0)?.unique_projects?.value ?? 0),
209228
name: [classification.key, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
210229
});
230+
seriesProjectRegion.push({
231+
color: getCssColor({ name: classification.key, prefix: "classification" }),
232+
data: funders.map((funder) => classification
233+
?.by_project_type.buckets?.find((project) => project.key === funder)
234+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.unique_projects?.value ?? 0), 0)
235+
?? 0),
236+
name: classification.key,
237+
});
211238
});
212239

213240
const title = `Disciplines par financeur de ${structure ? "l'établissement" : "la région"} ${name} ${getYearRangeLabel({ yearMax, yearMin })}`;
@@ -216,7 +243,7 @@ export default function Classifications2({ name }: { name: string | undefined })
216243
let dataLabel = function (this: any) {
217244
return `${this.y} projet${this.y > 1 ? 's' : ''}`;
218245
};
219-
let series = seriesProject.reverse();
246+
let series = structure ? seriesProject.reverse() : seriesProjectRegion.reverse();
220247
let stackLabel = function (this: any) {
221248
return `${this.total} projet${this.total > 1 ? 's' : ''}`;
222249
};
@@ -230,7 +257,7 @@ export default function Classifications2({ name }: { name: string | undefined })
230257
dataLabel = function (this: any) {
231258
return `${formatCompactNumber(this.y)} €`;
232259
};
233-
series = seriesBudget.reverse();
260+
series = structure ? seriesBudget.reverse() : seriesBudgetRegion.reverse();
234261
stackLabel = function (this: any) {
235262
return `${formatCompactNumber(this.total)} €`;
236263
};
@@ -244,7 +271,7 @@ export default function Classifications2({ name }: { name: string | undefined })
244271
dataLabel = function (this: any) {
245272
return `${formatCompactNumber(this.y)} €`;
246273
};
247-
series = seriesFunding.reverse();
274+
series = structure ? seriesFunding.reverse() : seriesFundingRegion.reverse();
248275
stackLabel = function (this: any) {
249276
return `${formatCompactNumber(this.total)} €`;
250277
};

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
101101
by_french_partners_participation: {
102102
terms: {
103103
field: "co_partners_fr_inst.keyword",
104-
order: { "sum_budget_participation": "desc" },
104+
order: { "sum_budget_funding": "desc" },
105105
},
106106
aggregations: {
107-
sum_budget_participation: {
107+
sum_budget_funding: {
108108
sum: {
109109
field: "participation_funding",
110110
},
@@ -125,7 +125,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
125125
missing: false,
126126
},
127127
aggregations: {
128-
sum_budget_participation: {
128+
sum_budget_funding: {
129129
sum: {
130130
field: "participation_funding",
131131
},
@@ -157,6 +157,9 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
157157
const seriesBudget: any = [];
158158
const seriesFunding: any = [];
159159
const seriesProject: any = [];
160+
const seriesBudgetRegion: any = [];
161+
const seriesFundingRegion: any = [];
162+
const seriesProjectRegion: any = [];
160163
const partnersBudget = data?.aggregations?.by_french_partners_budget?.buckets ?? [];
161164
const partnersFunding = data?.aggregations?.by_french_partners_participation?.buckets ?? [];
162165
const partnersProject = data?.aggregations?.by_french_partners_project?.buckets ?? [];
@@ -177,22 +180,38 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
177180
?.find((bucket) => bucket.key === 0)?.sum_budget?.value ?? 0),
178181
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
179182
});
183+
seriesBudgetRegion.push({
184+
color: getCssColor({ name: funder, prefix: "funder" }),
185+
data: partnersBudget.map((partner) => partner
186+
?.by_project_type.buckets?.find((project) => project.key === funder)
187+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_budget?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget?.value ?? 0), 0)
188+
?? 0),
189+
name: funder,
190+
});
180191
seriesFunding.push({
181192
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
182193
data: partnersFunding.map((partner) => partner.by_project_type.buckets
183194
?.find((project) => project.key === funder)?.is_coordinator?.buckets
184195
?.find((bucket) => bucket.key === 1)?.should_ignore_funding?.buckets
185-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
196+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
186197
name: [funder, getI18nLabel(i18n, 'coordinator')].join(' - '),
187198
});
188199
seriesFunding.push({
189200
color: getCssColor({ name: funder, prefix: "funder" }),
190201
data: partnersFunding.map((partner) => partner.by_project_type.buckets
191202
?.find((project) => project.key === funder)?.is_coordinator?.buckets
192203
?.find((bucket) => bucket.key === 0)?.should_ignore_funding?.buckets
193-
?.find((bucket) => bucket.key === 0)?.sum_budget_participation?.value ?? 0),
204+
?.find((bucket) => bucket.key === 0)?.sum_budget_funding?.value ?? 0),
194205
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
195206
});
207+
seriesFundingRegion.push({
208+
color: getCssColor({ name: funder, prefix: "funder" }),
209+
data: partnersFunding.map((partner) => partner
210+
?.by_project_type.buckets?.find((project) => project.key === funder)
211+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.should_ignore_funding?.buckets?.find((bucket) => bucket.key == 0)?.sum_budget_funding?.value ?? 0), 0)
212+
?? 0),
213+
name: funder,
214+
});
196215
seriesProject.push({
197216
color: { pattern: { ...pattern, backgroundColor: getCssColor({ name: funder, prefix: "funder" }) } },
198217
data: partnersProject.map((partner) => partner.by_project_type.buckets
@@ -207,6 +226,14 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
207226
?.find((bucket) => bucket.key === 0)?.unique_projects?.value ?? 0),
208227
name: [funder, getI18nLabel(i18n, 'not-coordinator')].join(' - '),
209228
});
229+
seriesProjectRegion.push({
230+
color: getCssColor({ name: funder, prefix: "funder" }),
231+
data: partnersProject.map((partner) => partner
232+
?.by_project_type.buckets?.find((project) => project.key === funder)
233+
?.is_coordinator?.buckets?.reduce((acc, curr) => acc + (curr?.unique_projects?.value ?? 0), 0)
234+
?? 0),
235+
name: funder,
236+
});
210237
});
211238
const categoriesProject = partnersProject.map((partner) => {
212239
const structure = Object.fromEntries(new URLSearchParams(partner.key));
@@ -228,7 +255,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
228255
let dataLabel = function (this: any) {
229256
return `${this.y} projet${this.y > 1 ? 's' : ''}`;
230257
};
231-
let series = seriesProject.reverse();
258+
let series = structure ? seriesProject.reverse() : seriesProjectRegion.reverse();
232259
let stackLabel = function (this: any) {
233260
return `${this.total} projet${this.total > 1 ? 's' : ''}`;
234261
};
@@ -243,7 +270,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
243270
dataLabel = function (this: any) {
244271
return `${formatCompactNumber(this.y)} €`;
245272
};
246-
series = seriesBudget.reverse();
273+
series = structure ? seriesBudget.reverse() : seriesBudgetRegion.reverse();
247274
stackLabel = function (this: any) {
248275
return `${formatCompactNumber(this.total)} €`;
249276
};
@@ -258,7 +285,7 @@ export default function FrenchPartners({ name }: { name: string | undefined }) {
258285
dataLabel = function (this: any) {
259286
return `${formatCompactNumber(this.y)} €`;
260287
};
261-
series = seriesFunding.reverse();
288+
series = structure ? seriesFunding.reverse() : seriesFundingRegion.reverse();
262289
stackLabel = function (this: any) {
263290
return `${formatCompactNumber(this.total)} €`;
264291
};

0 commit comments

Comments
 (0)