refactor: change following CR on #2905

pull/2922/head
Johan Girod 2024-03-06 15:00:18 +01:00
parent 090385e70a
commit 3d09d5aaf6
2 changed files with 24 additions and 23 deletions

View File

@ -10,7 +10,7 @@ describe('Secondary pages', function () {
cy.contains('Statistiques')
})
it.only('Statistics page should be RGAA compliant', function () {
it('Statistics page should be RGAA compliant', function () {
cy.visit('/stats')
cy.contains('Activer le mode accessibilité').click()
cy.get('table').should('be.visible')

View File

@ -105,29 +105,30 @@ function filterIs(value: string, filter: Filter | ''): boolean {
return typeof filter !== 'string' && filter.chapter2 === value
}
function mergeVisites(...visites: Visites[]) {
const visitesObjects = visites.map((v) =>
Object.fromEntries(v.map((v) => [v.date, v.nombre]))
)
const dates = new Set(visites.flatMap((v) => v.map((v) => v.date)))
function mergeVisites(...listesDeVisites: Visites[]): Visites {
return Object.values(
listesDeVisites
.flat()
.reduce<Record<string, Visites[number]>>((acc, visite) => {
const date = visite.date
acc[date] ??= {
date,
nombre: {
accueil: 0,
simulation_commencee: 0,
simulation_terminee: 0,
},
}
acc[date].nombre.accueil += visite.nombre.accueil
acc[date].nombre.simulation_commencee +=
visite.nombre.simulation_commencee
acc[date].nombre.simulation_terminee ??=
(acc[date].nombre.simulation_terminee || 0) +
(visite.nombre.simulation_terminee || 0)
return Array.from(dates).map((date) => ({
date,
nombre: {
accueil: visitesObjects.reduce(
(acc, v) => acc + (v[date]?.accueil || 0),
0
),
simulation_commencee: visitesObjects.reduce(
(acc, v) => acc + (v[date]?.simulation_commencee || 0),
0
),
simulation_terminee: visitesObjects.reduce(
(acc, v) => acc + (v[date]?.simulation_terminee || 0),
0
),
},
}))
return acc
}, {})
).sort((a, b) => (a.date < b.date ? -1 : 1))
}
const isPAM = (name: string | undefined) =>