Skip to content

Commit

Permalink
fix(stats): add new age range
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Mar 25, 2024
1 parent 16d44a4 commit 799917c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ async function getStructureStatsQuestionsAtDateValidUsagers({
,count(distinct uh."usagerUUID") filter (where date_part('year', age( $3, u."dateNaissance" at time zone 'utc')) :: int < 18) as v_u_age_mineur
,count(distinct uh."usagerUUID") filter (where date_part('year', age( $3, u."dateNaissance" at time zone 'utc')) :: int >= 18) as v_u_age_majeur
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_0_14' ) as v_u_age_0_14
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_15_19' ) as v_u_age_15_19
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_20_24' ) as v_u_age_20_24
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_25_29' ) as v_u_age_25_29
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_0_17' ) as v_u_age_0_17
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_18_25' ) as v_u_age_18_25
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_26_29' ) as v_u_age_26_29
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_30_34' ) as v_u_age_30_34
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_35_39' ) as v_u_age_35_39
,count(distinct usager_tranche.uuid) filter ( where usager_tranche.tranche_age = 'T_40_44' ) as v_u_age_40_44
Expand Down Expand Up @@ -138,10 +138,9 @@ async function getStructureStatsQuestionsAtDateValidUsagers({
select
u2.uuid,
CASE
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 15 THEN 'T_0_14'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 20 THEN 'T_15_19'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 25 THEN 'T_20_24'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 30 THEN 'T_25_29'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 18 THEN 'T_0_17'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 26 THEN 'T_18_25'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 30 THEN 'T_26_29'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 35 THEN 'T_30_34'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 40 THEN 'T_35_39'
WHEN date_part('year', age( $3, u2."dateNaissance" at time zone 'utc' )) :: int < 45 THEN 'T_40_44'
Expand Down Expand Up @@ -256,10 +255,9 @@ async function getStructureStatsQuestionsAtDateValidUsagers({
usagers: {
mineurs: parseInt(r.v_u_age_mineur, 10),
majeurs: parseInt(r.v_u_age_majeur, 10),
t_0_14: parseInt(r.v_u_age_0_14, 10),
t_15_19: parseInt(r.v_u_age_15_19, 10),
t_20_24: parseInt(r.v_u_age_20_24, 10),
t_25_29: parseInt(r.v_u_age_25_29, 10),
t_0_17: parseInt(r.v_u_age_0_17, 10),
t_18_25: parseInt(r.v_u_age_18_25, 10),
t_26_29: parseInt(r.v_u_age_26_29, 10),
t_30_34: parseInt(r.v_u_age_30_34, 10),
t_35_39: parseInt(r.v_u_age_35_39, 10),
t_40_44: parseInt(r.v_u_age_40_44, 10),
Expand Down Expand Up @@ -346,10 +344,9 @@ async function getStructureStatsQuestionsAtDateValidUsagers({
usagers: {
mineurs: 0,
majeurs: 0,
t_0_14: 0,
t_15_19: 0,
t_20_24: 0,
t_25_29: 0,
t_0_17: 0,
t_18_25: 0,
t_26_29: 0,
t_30_34: 0,
t_35_39: 0,
t_40_44: 0,
Expand Down
Binary file modified packages/backend/src/excel/_templates/export-structure-stats.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,10 @@ function renderSection1ValidUsagers(context: {
value: data.age.usagers.majeurs,
});
worksheetRendered.renderCell(i++, "c", {
value: data.age.usagers.t_0_14,
value: data.age.usagers.t_18_25,
});
worksheetRendered.renderCell(i++, "c", {
value: data.age.usagers.t_15_19,
});
worksheetRendered.renderCell(i++, "c", {
value: data.age.usagers.t_20_24,
});
worksheetRendered.renderCell(i++, "c", {
value: data.age.usagers.t_25_29,
value: data.age.usagers.t_26_29,
});
worksheetRendered.renderCell(i++, "c", {
value: data.age.usagers.t_30_34,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ describe("structureStatsInPeriodGenerator", () => {
usagers: {
majeurs: 3,
mineurs: 0,
t_0_14: 0,
t_15_19: 0,
t_20_24: 1,
t_25_29: 0,
t_0_17: 1,
t_18_25: 1,
t_26_29: 0,
t_30_34: 1,
t_35_39: 0,
t_40_44: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export interface StructureStatsTranchesAge {
mineurs: number;
majeurs: number;
t_0_14: number;
t_15_19: number;
t_20_24: number;
t_25_29: number;
t_0_17: number;
t_18_25: number;
t_26_29: number;
t_30_34: number;
t_35_39: number;
t_40_44: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,27 +299,15 @@ <h2>
</td>
</tr>
<tr>
<th scope="row" class="soustable">Moins de 15 ans</th>
<th scope="row" class="soustable">18-25 ans</th>
<td class="stats-table-value">
{{ stats.data.validUsagers.age.usagers.t_0_14 }}
{{ stats.data.validUsagers.age.usagers.t_18_25 }}
</td>
</tr>
<tr>
<th scope="row" class="soustable">15-19 ans</th>
<th scope="row" class="soustable">26-29 ans</th>
<td class="stats-table-value">
{{ stats.data.validUsagers.age.usagers.t_15_19 }}
</td>
</tr>
<tr>
<th scope="row" class="soustable">20-24 ans</th>
<td class="stats-table-value">
{{ stats.data.validUsagers.age.usagers.t_20_24 }}
</td>
</tr>
<tr>
<th scope="row" class="soustable">25-29 ans</th>
<td class="stats-table-value">
{{ stats.data.validUsagers.age.usagers.t_25_29 }}
{{ stats.data.validUsagers.age.usagers.t_26_29 }}
</td>
</tr>
<tr>
Expand Down

0 comments on commit 799917c

Please sign in to comment.