Skip to content

Commit

Permalink
fix(stats): add cache to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Dec 28, 2023
1 parent 1ddea6d commit 5ac8b44
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fileignoreconfig:
- filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
checksum: f830f17c3ba34a7b96732625490c18b91d654a508c4c6d5f2d8ee98e658f3a8a
checksum: 1cdf7754b06271ad65a5f821a6140c6e7327a91cba16d980c2c39bdb40e75089
- filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql
checksum: 85bd13b83873b42839f02568ff1ce9f24c43b345ba94b78dc3638d83f9f30efd
checksum: 507d8ae2da670759be7035f4e6f6e0ee4568396ed65c9c843e4e7acddd83876f
- filename: packages/backend/src/_common/decorators/IsValidPasswordDecorator.ts
checksum: f0d4b3cd2e6e2d9b1e0271c34d64adacf87a5f1e7a505402a20869962543608d
- filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts
Expand Down
Binary file modified _scripts/db/dumps/domifa_test.postgres.custom.gz
Binary file not shown.
28 changes: 14 additions & 14 deletions _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ManualMigration1703081808851 implements MigrationInterface {
//
}

private counteMigratedStats(): Promise<number> {
private async counteMigratedStats(): Promise<number> {
return usagerHistoryRepository.countBy({ migrated: false });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function countTotalUsagers(structuresId?: number[]): Promise<number> {
}

async function countTotalActifs(): Promise<number> {
const usagers: [{ actifs: number }] = await usagerRepository.query(`
const usagers: [{ actifs: string }] = await usagerRepository.query(`
SELECT
COUNT(DISTINCT uh."usagerUUID") + COALESCE(SUM(jsonb_array_length(state->'ayantsDroits')), 0) AS "actifs"
FROM "usager_history" uh JOIN usager u ON uh."usagerUUID" = u.uuid JOIN jsonb_array_elements(uh.states) AS state ON true
Expand All @@ -138,7 +138,7 @@ async function countTotalActifs(): Promise<number> {
AND (state->>'historyEndDate' is null OR (state->>'historyEndDate')::timestamptz >= CURRENT_DATE + INTERVAL '1 day' )
`);

return usagers[0].actifs;
return parseInt(usagers[0].actifs, 10);
}

async function countMigratedUsagers(): Promise<number> {
Expand Down
Loading

0 comments on commit 5ac8b44

Please sign in to comment.