Skip to content

Commit

Permalink
fix(stat): review nationalities count
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Ribiere committed Dec 15, 2023
1 parent a80f229 commit adef0b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/classes/OpsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class OpsData {
windForce = NaN
waveHeight = NaN
boatType = ""
nbNationalities = NaN
nbNationalities = ""
transfertType = ""
imageSrc: string[] = []
videoSrc: string[] = []
Expand Down Expand Up @@ -77,7 +77,7 @@ const convertOpsData = function (rawOpsData: {[key: string]: string}, metadataEr
res.windForce = parseInt(rawOpsData.windForce)
res.waveHeight = parseInt(rawOpsData.waveHeight)
res.boatType = rawOpsData.boatType
res.nbNationalities = parseInt(rawOpsData.nbNationalities)
res.nbNationalities = rawOpsData.typeNationalities
res.transfertType = rawOpsData.transfertType
res.imageSrc = rawOpsData.imageSrc ? rawOpsData.imageSrc.split(";") : []
res.videoSrc = rawOpsData.videoSrv ? rawOpsData.videoSrv.split(";") : []
Expand Down
7 changes: 5 additions & 2 deletions src/classes/PopUpAndStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const fillPopUp = function (data: OpsData) {
setInnerText("popUpPregnant", numberToString(data.pregnantWomen))
setInnerText("popUpUnaccompagnied", numberToString(data.under18unacc))
setInnerText("popUpChildren", numberToString(data.under5))
setInnerText("popUpNationalities", numberToString(data.nbNationalities))
setInnerText("popUpNationalities", numberToString(data.nbNationalities ? data.nbNationalities.split(";").length : 0))
setInnerText("popUpWind", numberToString(data.windForce))
setInnerText("popUpWave", numberToString(data.waveHeight))
setInnerText("popUpLat", numberToString(data.latitude))
Expand Down Expand Up @@ -58,6 +58,7 @@ export const updateStats = function (minDate: Date, maxDate: Date, timeFilteredD
const nbRescueOps = store.allData.filter(el => el.typeOps === "Rescue").length
const nbPeopleAssisted = store.allData.filter(el => el.nbSurvivor).map(
el => el.nbSurvivor).reduce((partialSum, a) => partialSum + a, 0)
const nationalitiesList = []
for (const data of timeFilteredData) {
nbSurvivor = data.nbSurvivor ? nbSurvivor + data.nbSurvivor : nbSurvivor
female = data.female ? female + data.female : female
Expand All @@ -66,9 +67,11 @@ export const updateStats = function (minDate: Date, maxDate: Date, timeFilteredD
pregnantwomen = data.pregnantWomen ? pregnantwomen + data.pregnantWomen : pregnantwomen
under18unacc = data.under18unacc ? under18unacc + data.under18unacc : under18unacc
under5 = data.under5 ? under5 + data.under5 : under5
nbNationalities = data.nbNationalities ? Math.max(nbNationalities, data.nbNationalities) : nbNationalities
if (data.nbNationalities) nationalitiesList.push(data.nbNationalities.split(";"))
// nbNationalities = data.nbNationalities ? Math.max(nbNationalities, data.nbNationalities) : nbNationalities
days.add(data.date)
}
nbNationalities = [...new Set(nationalitiesList.flat())].length
setInnerText("statsNbSurvivor", numberToString(nbSurvivor))
setInnerText("statsFemale", numberToString(female))
setInnerText("statsMale", numberToString(male))
Expand Down

0 comments on commit adef0b4

Please sign in to comment.