Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Ajout stat nombre parrainage #2746

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
Loading