Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
fix(statistiques): corrige les calculs sur les granulats marins (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoBahamut authored Jan 18, 2021
1 parent 39e2475 commit b48ea9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions src/api/graphql/resolvers/statistiques-granulats-marins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type IStatsGranulatsMarinsTitresTypesHistorique =
| 'titresCxw'

type IStatsGranulatsMarinsTitresTypesInstant =
| 'titresInstructionPrw'
| 'titresInstructionExploration'
| 'titresValPrw'
| 'titresDmiCxw'
| 'titresInstructionExploitation'
| 'titresValCxw'

const statistiquesGranulatsMarinsTitresGet = (
Expand Down Expand Up @@ -67,33 +67,32 @@ const statistiquesGranulatsMarinsInstantBuild = (titres: ITitre[]) => {
titre.surfaceEtape &&
titre.surfaceEtape.surface
) {
if (titre.typeId! === 'prw') {
if (['arw', 'apw', 'prw'].includes(titre.typeId!)) {
acc.surfaceExploration += titre.surfaceEtape.surface
if (['mod', 'dmi'].includes(titre.statutId!)) {
acc.titresInstructionExploration++
}
} else {
acc.surfaceExploitation += titre.surfaceEtape.surface
if (['mod', 'dmi'].includes(titre.statutId!)) {
acc.titresInstructionExploitation++
}
}
const id = camelcase(
`titres-${titre.statutId!}-${titre.typeId!}`
) as IStatsGranulatsMarinsTitresTypesInstant

acc[id]++

if (
titre.typeId! === 'prw' &&
['mod', 'dmi'].includes(titre.statutId!)
) {
acc.titresInstructionPrw++
}
}

return acc
},
{
surfaceExploration: 0,
surfaceExploitation: 0,
titresInstructionPrw: 0,
titresInstructionExploration: 0,
titresValPrw: 0,
titresDmiCxw: 0,
titresInstructionExploitation: 0,
titresValCxw: 0
}
)
Expand Down Expand Up @@ -176,7 +175,7 @@ const statistiquesGranulatsMarins = async () => {
const titres = await titresGet(
{
domainesIds: ['w'],
typesIds: ['pr', 'ax', 'px', 'cx']
typesIds: ['ar', 'ap', 'pr', 'ax', 'px', 'cx']
},
{
fields: {
Expand Down
4 changes: 2 additions & 2 deletions src/api/graphql/schemas/statistiques.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ type StatistiquesGranulatsMarins {
annees: [StatistiquesGranulatsMarinsAnnee]
surfaceExploration: Int
surfaceExploitation: Int
titresInstructionPrw: Int
titresInstructionExploration: Int
titresValPrw: Int
titresDmiCxw: Int
titresInstructionExploitation: Int
titresValCxw: Int
}

0 comments on commit b48ea9c

Please sign in to comment.