Skip to content

Commit

Permalink
✨ Ajout stat nombre parrainage (#2746)
Browse files Browse the repository at this point in the history
  • Loading branch information
HubM authored Feb 18, 2025
1 parent fd912da commit 381d714
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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 @@ -2,6 +2,10 @@ import {
cleanNombreTotalProjet,
computeNombreTotalProjet,
} from './projet/nombreTotalProjet.statistic';
import {
cleanNombreParrainage,
computeNombreParrainage,
} from './utilisateur/nombreParrainage.statistic';
import {
cleanNombrePorteurInscrit,
computeNombrePorteurInscrit,
Expand All @@ -10,9 +14,11 @@ import {
export const cleanStatistiquesPubliques = async () => {
await cleanNombreTotalProjet();
await cleanNombrePorteurInscrit();
await cleanNombreParrainage();
};

export const computeStatistiquesPubliques = async () => {
await computeNombreTotalProjet();
await computeNombrePorteurInscrit();
await computeNombreParrainage();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { executeQuery } from '@potentiel-libraries/pg-helpers';

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

const statisticType = 'nombreParrainage';

export const cleanNombreParrainage = cleanScalarStatistic(statisticType);

export const computeNombreParrainage = () =>
executeQuery(
`
insert
into
domain_public_statistic.scalar_statistic
values(
$1,
(
select
count(distinct(users.email))
from
notifications
inner join
users
on notifications.message ->> 'email' = users.email
where
type = 'project-invitation'
)
)
`,
statisticType,
);

0 comments on commit 381d714

Please sign in to comment.