Skip to content

Commit

Permalink
Stat total mainlevées accordées (#2790)
Browse files Browse the repository at this point in the history
* ✨ Stat Nombre Total de mainlevées accordées

* 🎨 Utilisation d'un like sur les évènements de l'event store pour plus de flexibilité (si les events évoluent)
  • Loading branch information
HubM authored Feb 27, 2025
1 parent 1704761 commit 52bc81c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
Binary file modified .database/metabase-dev.dump
Binary file not shown.
Binary file modified .database/potentiel-dev.dump
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/statistiques/statistiques-publiques/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ import {
cleanTotalPuissanceProjetAvecMainlevéeAccordée,
computeTotalPuissanceProjetAvecMainlevéeAccordée,
} from './projet/totalPuissanceProjetAvecMainlevéeAccordée.statistic';
import {
cleanNombreTotalMainlevéeAccordée,
computeNombreTotalMainlevéeAccordée,
} from './projet/nombreTotalMainlevéeAccordée.statistic';

export const cleanStatistiquesPubliques = async () => {
await cleanNombreTotalProjet();
Expand All @@ -90,6 +94,7 @@ export const cleanStatistiquesPubliques = async () => {
await cleanProjetLauréatParDépartement();
await cleanUtilisateurCréation();
await cleanTotalPuissanceProjetAvecMainlevéeAccordée();
await cleanNombreTotalMainlevéeAccordée();
};

export const computeStatistiquesPubliques = async () => {
Expand All @@ -111,4 +116,5 @@ export const computeStatistiquesPubliques = async () => {
await computeProjetLauréatParDépartement();
await computeUtilisateurCréation();
await computeTotalPuissanceProjetAvecMainlevéeAccordée();
await computeNombreTotalMainlevéeAccordée();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { executeQuery } from '@potentiel-libraries/pg-helpers';

import { cleanScalarStatistic } from '../_utils/cleanScalarStatistic';

const statisticType = 'nombreTotalMainlevéeAccordée';

export const cleanNombreTotalMainlevéeAccordée = cleanScalarStatistic(statisticType);

export const computeNombreTotalMainlevéeAccordée = () =>
executeQuery(
`
insert
into
domain_public_statistic.scalar_statistic
values(
$1,
(
select
count(distinct(payload->>'identifiantProjet'))
from event_store.event_stream es
where es.type like 'DemandeMainlevéeGarantiesFinancièresAccordée-V%'
)
)
`,
statisticType,
);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const computeTotalPuissanceProjetAvecMainlevéeAccordée = () =>
sum(p."puissance") as "value"
from projects p
where p."appelOffreId" || '#' || p."periodeId" || '#' || p."familleId" || '#' || p."numeroCRE" in (
select distinct(payload->>'identifiantProjet') from event_store.event_stream es where es.type = 'DemandeMainlevéeGarantiesFinancièresAccordée-V1'
select distinct(payload->>'identifiantProjet') from event_store.event_stream es where es.type like 'DemandeMainlevéeGarantiesFinancièresAccordée-V%'
)
)
)
Expand Down

0 comments on commit 52bc81c

Please sign in to comment.