diff --git a/bin/presence.ts b/bin/presence.ts index e70ca61d..66862c22 100644 --- a/bin/presence.ts +++ b/bin/presence.ts @@ -82,6 +82,25 @@ async function run() { writterData.presences[file.replace(/\.csv$/, "")] = presences.sort(sortByDate); + writterData.presencesStats = writterData.presencesStats || {}; + writterData.presencesStats[file.replace(/\.csv$/, "")] = presences.reduce( + (stats, presence) => ({ + total: stats.total + 1, + present: stats.present + (presence.present ? 1 : 0), + arrivedLate: stats.arrivedLate + (presence.arrivedLate ? 1 : 0), + leftBeforeTheEnd: + stats.leftBeforeTheEnd + (presence.leftBeforeTheEnd ? 1 : 0), + delegation: stats.delegation + (presence.delegation ? 1 : 0), + }), + { + total: 0, + present: 0, + arrivedLate: 0, + leftBeforeTheEnd: 0, + delegation: 0, + } + ); + await writeFile( pathJoin("contents", "writters", `${persons[personId].id}.json`), JSON.stringify(writterData, null, 2) diff --git a/contents/writters/agnes-dupuis.json b/contents/writters/agnes-dupuis.json index 55986068..c1698843 100644 --- a/contents/writters/agnes-dupuis.json +++ b/contents/writters/agnes-dupuis.json @@ -467,5 +467,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/anissa-bouchaboun.json b/contents/writters/anissa-bouchaboun.json index 6082c127..4229f4a0 100644 --- a/contents/writters/anissa-bouchaboun.json +++ b/contents/writters/anissa-bouchaboun.json @@ -453,5 +453,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 15, + "arrivedLate": 2, + "leftBeforeTheEnd": 0, + "delegation": 7 + } } } \ No newline at end of file diff --git a/contents/writters/anne-colin.json b/contents/writters/anne-colin.json index 8192be2c..ada28e52 100644 --- a/contents/writters/anne-colin.json +++ b/contents/writters/anne-colin.json @@ -521,5 +521,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 20, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/anne-sophie-audegond.json b/contents/writters/anne-sophie-audegond.json index 332ba5d3..fea82305 100644 --- a/contents/writters/anne-sophie-audegond.json +++ b/contents/writters/anne-sophie-audegond.json @@ -451,5 +451,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 14, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 7 + } } } \ No newline at end of file diff --git a/contents/writters/auriane-ait-lasri.json b/contents/writters/auriane-ait-lasri.json index f21f27bc..fd43613d 100644 --- a/contents/writters/auriane-ait-lasri.json +++ b/contents/writters/auriane-ait-lasri.json @@ -1196,5 +1196,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 18, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 4 + } } } \ No newline at end of file diff --git a/contents/writters/avida-oulahcene.json b/contents/writters/avida-oulahcene.json index 58816077..77537a59 100644 --- a/contents/writters/avida-oulahcene.json +++ b/contents/writters/avida-oulahcene.json @@ -447,5 +447,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 15, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 6 + } } } \ No newline at end of file diff --git a/contents/writters/carolle-divrechy.json b/contents/writters/carolle-divrechy.json index ecf3f018..dd62b859 100644 --- a/contents/writters/carolle-divrechy.json +++ b/contents/writters/carolle-divrechy.json @@ -499,5 +499,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 14, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 8 + } } } \ No newline at end of file diff --git a/contents/writters/chantal-rybak.json b/contents/writters/chantal-rybak.json index c3fd75f4..46dea431 100644 --- a/contents/writters/chantal-rybak.json +++ b/contents/writters/chantal-rybak.json @@ -1009,5 +1009,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 19, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/coline-craeye.json b/contents/writters/coline-craeye.json index 34210834..7b45dcaf 100644 --- a/contents/writters/coline-craeye.json +++ b/contents/writters/coline-craeye.json @@ -1219,5 +1219,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/eric-lemaitre.json b/contents/writters/eric-lemaitre.json index 5abfafe0..2c62f03e 100644 --- a/contents/writters/eric-lemaitre.json +++ b/contents/writters/eric-lemaitre.json @@ -447,5 +447,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 15, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 6 + } } } \ No newline at end of file diff --git a/contents/writters/francois-guiffard.json b/contents/writters/francois-guiffard.json index d9824331..8ddb31b0 100644 --- a/contents/writters/francois-guiffard.json +++ b/contents/writters/francois-guiffard.json @@ -1621,5 +1621,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 15, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 1 + } } } \ No newline at end of file diff --git a/contents/writters/franz-quatreboeufs.json b/contents/writters/franz-quatreboeufs.json index 4128a9f1..57f8c58a 100644 --- a/contents/writters/franz-quatreboeufs.json +++ b/contents/writters/franz-quatreboeufs.json @@ -814,5 +814,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 2, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/frederic-chereau.json b/contents/writters/frederic-chereau.json index 8b0124b7..67c0499a 100644 --- a/contents/writters/frederic-chereau.json +++ b/contents/writters/frederic-chereau.json @@ -4090,5 +4090,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/guy-cannie.json b/contents/writters/guy-cannie.json index 4642fdd4..be3ede7c 100644 --- a/contents/writters/guy-cannie.json +++ b/contents/writters/guy-cannie.json @@ -2484,5 +2484,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 18, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/guy-caruyer.json b/contents/writters/guy-caruyer.json index 81f1d24e..418cc308 100644 --- a/contents/writters/guy-caruyer.json +++ b/contents/writters/guy-caruyer.json @@ -510,5 +510,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/guy-lagache.json b/contents/writters/guy-lagache.json index 1dee2df6..ceb7e089 100644 --- a/contents/writters/guy-lagache.json +++ b/contents/writters/guy-lagache.json @@ -450,5 +450,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 15, + "present": 13, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/hocine-mazy.json b/contents/writters/hocine-mazy.json index 1f53c615..7e49779e 100644 --- a/contents/writters/hocine-mazy.json +++ b/contents/writters/hocine-mazy.json @@ -479,5 +479,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 19, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/jamila-mekki.json b/contents/writters/jamila-mekki.json index 0f7748b8..585dcf1b 100644 --- a/contents/writters/jamila-mekki.json +++ b/contents/writters/jamila-mekki.json @@ -475,5 +475,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 18, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/jean-christophe-leclercq.json b/contents/writters/jean-christophe-leclercq.json index 42c3ba5d..015d30d2 100644 --- a/contents/writters/jean-christophe-leclercq.json +++ b/contents/writters/jean-christophe-leclercq.json @@ -561,5 +561,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 21, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 1 + } } } \ No newline at end of file diff --git a/contents/writters/jean-marie-dupire.json b/contents/writters/jean-marie-dupire.json index 3eb4200f..9bfede8c 100644 --- a/contents/writters/jean-marie-dupire.json +++ b/contents/writters/jean-marie-dupire.json @@ -455,5 +455,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 12, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 8 + } } } \ No newline at end of file diff --git a/contents/writters/jean-michel-leroy.json b/contents/writters/jean-michel-leroy.json index 6ca7e5ff..b0d9dc7f 100644 --- a/contents/writters/jean-michel-leroy.json +++ b/contents/writters/jean-michel-leroy.json @@ -479,5 +479,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 19, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/jessy-kaboul.json b/contents/writters/jessy-kaboul.json index 9f465243..23b6d080 100644 --- a/contents/writters/jessy-kaboul.json +++ b/contents/writters/jessy-kaboul.json @@ -411,5 +411,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 7, + "present": 6, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 1 + } } } \ No newline at end of file diff --git a/contents/writters/katia-bittner.json b/contents/writters/katia-bittner.json index 1cceaf5b..81875721 100644 --- a/contents/writters/katia-bittner.json +++ b/contents/writters/katia-bittner.json @@ -634,5 +634,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 21, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 1 + } } } \ No newline at end of file diff --git a/contents/writters/khadija-ahantat.json b/contents/writters/khadija-ahantat.json index 47fde503..00c681fe 100644 --- a/contents/writters/khadija-ahantat.json +++ b/contents/writters/khadija-ahantat.json @@ -465,5 +465,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/marie-delattre.json b/contents/writters/marie-delattre.json index 0fcf577f..101d0c9b 100644 --- a/contents/writters/marie-delattre.json +++ b/contents/writters/marie-delattre.json @@ -635,5 +635,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 20, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/maxime-decupper-laud.json b/contents/writters/maxime-decupper-laud.json index 71f6d0b2..5cdbb46c 100644 --- a/contents/writters/maxime-decupper-laud.json +++ b/contents/writters/maxime-decupper-laud.json @@ -488,5 +488,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 17, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 5 + } } } \ No newline at end of file diff --git a/contents/writters/michael-doziere.json b/contents/writters/michael-doziere.json index dc51e525..4313906c 100644 --- a/contents/writters/michael-doziere.json +++ b/contents/writters/michael-doziere.json @@ -475,5 +475,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 19, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/mohamed-felouki.json b/contents/writters/mohamed-felouki.json index b5e1d817..de83455f 100644 --- a/contents/writters/mohamed-felouki.json +++ b/contents/writters/mohamed-felouki.json @@ -455,5 +455,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 14, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 8 + } } } \ No newline at end of file diff --git a/contents/writters/mohamed-kheraki.json b/contents/writters/mohamed-kheraki.json index 76939a2a..0a7cc9fd 100644 --- a/contents/writters/mohamed-kheraki.json +++ b/contents/writters/mohamed-kheraki.json @@ -482,5 +482,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 18, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/nadia-bony.json b/contents/writters/nadia-bony.json index dc7c1434..6d5f712d 100644 --- a/contents/writters/nadia-bony.json +++ b/contents/writters/nadia-bony.json @@ -391,5 +391,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 12, + "present": 9, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/nathalie-apers.json b/contents/writters/nathalie-apers.json index 4cad05c1..ea307fe0 100644 --- a/contents/writters/nathalie-apers.json +++ b/contents/writters/nathalie-apers.json @@ -477,5 +477,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 20, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/nora-cherki.json b/contents/writters/nora-cherki.json index cdf7a3d0..0ea4fc62 100644 --- a/contents/writters/nora-cherki.json +++ b/contents/writters/nora-cherki.json @@ -770,5 +770,14 @@ } } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 18, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 4 + } } } \ No newline at end of file diff --git a/contents/writters/salima-boukentar.json b/contents/writters/salima-boukentar.json index fc9f07c0..579bfb15 100644 --- a/contents/writters/salima-boukentar.json +++ b/contents/writters/salima-boukentar.json @@ -477,5 +477,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 19, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 3 + } } } \ No newline at end of file diff --git a/contents/writters/sebastien-lanclu.json b/contents/writters/sebastien-lanclu.json index 9a35ef7d..d77e41b9 100644 --- a/contents/writters/sebastien-lanclu.json +++ b/contents/writters/sebastien-lanclu.json @@ -469,5 +469,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/stephanie-stiernon.json b/contents/writters/stephanie-stiernon.json index 71450215..d5f10230 100644 --- a/contents/writters/stephanie-stiernon.json +++ b/contents/writters/stephanie-stiernon.json @@ -750,5 +750,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/thibaut-francois.json b/contents/writters/thibaut-francois.json index 90c6ac88..c9cfb2a8 100644 --- a/contents/writters/thibaut-francois.json +++ b/contents/writters/thibaut-francois.json @@ -1490,5 +1490,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 17, + "arrivedLate": 0, + "leftBeforeTheEnd": 1, + "delegation": 5 + } } } \ No newline at end of file diff --git a/contents/writters/virginie-malolepszy.json b/contents/writters/virginie-malolepszy.json index 6d6e7952..126ebd67 100644 --- a/contents/writters/virginie-malolepszy.json +++ b/contents/writters/virginie-malolepszy.json @@ -375,5 +375,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 10, + "present": 10, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/contents/writters/xavier-thierry.json b/contents/writters/xavier-thierry.json index 02d7d37c..1edcec73 100644 --- a/contents/writters/xavier-thierry.json +++ b/contents/writters/xavier-thierry.json @@ -512,5 +512,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 21, + "arrivedLate": 1, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/yves-piquot.json b/contents/writters/yves-piquot.json index b63928ec..b39bf6e6 100644 --- a/contents/writters/yves-piquot.json +++ b/contents/writters/yves-piquot.json @@ -603,5 +603,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 20, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 2 + } } } \ No newline at end of file diff --git a/contents/writters/yvette-wattebled.json b/contents/writters/yvette-wattebled.json index ec454774..e83722b4 100644 --- a/contents/writters/yvette-wattebled.json +++ b/contents/writters/yvette-wattebled.json @@ -287,5 +287,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 10, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 10 + } } } \ No newline at end of file diff --git a/contents/writters/yvon-sipieter.json b/contents/writters/yvon-sipieter.json index b07be733..fc6cc010 100644 --- a/contents/writters/yvon-sipieter.json +++ b/contents/writters/yvon-sipieter.json @@ -469,5 +469,14 @@ "present": true } ] + }, + "presencesStats": { + "cm-douai": { + "total": 22, + "present": 22, + "arrivedLate": 0, + "leftBeforeTheEnd": 0, + "delegation": 0 + } } } \ No newline at end of file diff --git a/src/pages/elu-es/[id].tsx b/src/pages/elu-es/[id].tsx index d5ee66b8..cae1628a 100644 --- a/src/pages/elu-es/[id].tsx +++ b/src/pages/elu-es/[id].tsx @@ -85,6 +85,32 @@ const Entry = ({ entry }: Props) => { {Object.keys(entry.presences).map((instance) => ( {INSTANCES[instance]} + + + ✅ Présences : {entry.presencesStats[instance].present}/ + {entry.presencesStats[instance].total} + + + ❌ Absence :{" "} + {entry.presencesStats[instance].total - + entry.presencesStats[instance].present} + /{entry.presencesStats[instance].total} + + + ⌚ Retards : {entry.presencesStats[instance].arrivedLate}/ + {entry.presencesStats[instance].total} + + + 🏃🏽 Départs anticipés :{" "} + {entry.presencesStats[instance].leftBeforeTheEnd}/ + {entry.presencesStats[instance].total} + + + 🤾 Pouvoirs donnés :{" "} + {entry.presencesStats[instance].delegation}/ + {entry.presencesStats[instance].total} + + {entry.presences[instance].map((presence) => ( diff --git a/src/pages/elu-es/index.tsx b/src/pages/elu-es/index.tsx index c1407f75..07ba9948 100644 --- a/src/pages/elu-es/index.tsx +++ b/src/pages/elu-es/index.tsx @@ -102,7 +102,7 @@ export const entriesToBaseListingMetadata = ( const description = "Retrouvez toustes les élu·es du Douaisis cité·es sur ce site et les statistiques relatives à leurs tribunes."; const entries = baseEntries - .map(({ presences, ...stats }) => { + .map(({ presences, presencesStats, ...stats }) => { return { id: toASCIIString(stats.name), date: stats.writtings.length @@ -112,6 +112,7 @@ export const entriesToBaseListingMetadata = ( description: `Fiche de l'élu·e ${stats.name}`, stats, ...(presences ? { presences } : {}), + ...(presencesStats ? { presencesStats } : {}), illustration: { url: `images/portraits/${stats.portrait}`, alt: `Portrait de ${stats.name}`, diff --git a/src/utils/writters.ts b/src/utils/writters.ts index 0e4cd812..67e3db66 100644 --- a/src/utils/writters.ts +++ b/src/utils/writters.ts @@ -9,6 +9,13 @@ export type PresenceItem = { arrivedLate?: boolean; leftBeforeTheEnd?: boolean; }; +export type PresenceStatItem = { + total: number; + present: number; + arrivedLate: number; + leftBeforeTheEnd: number; + delegation: number; +}; export type OccurenceItem = { id: string; date: string; @@ -62,6 +69,7 @@ export type WritterStats = { country: string; portrait: string; presences?: Record; + presencesStats?: Record; } & StatsData; export type Writter = { @@ -75,6 +83,7 @@ export type Writter = { }; stats: Omit; presences?: Record; + presencesStats?: Record; }; export function authorToWritterFilename(author: string) {