diff --git a/website/src/components/IndexPage/getOrganismStatistics.ts b/website/src/components/IndexPage/getOrganismStatistics.ts index e8d106bc6..02623134c 100644 --- a/website/src/components/IndexPage/getOrganismStatistics.ts +++ b/website/src/components/IndexPage/getOrganismStatistics.ts @@ -1,7 +1,8 @@ import { DateTime, FixedOffsetZone } from 'luxon'; import { LapisClient } from '../../services/lapisClient.ts'; -import { RELEASED_AT_FIELD } from '../../settings.ts'; +import { RELEASED_AT_FIELD, VERSION_STATUS_FIELD, IS_REVOCATION_FIELD } from '../../settings.ts'; +import { siloVersionStatuses } from '../../types/lapis'; export type OrganismStatistics = { totalSequences: number; @@ -49,7 +50,8 @@ const getTotalAndLastUpdatedAt = async ( const client = LapisClient.createForOrganism(organism); return ( await client.call('aggregated', { - version: 1, + [VERSION_STATUS_FIELD]: siloVersionStatuses.latestVersion, + [IS_REVOCATION_FIELD]: 'false', }) ) .map((x) => ({ @@ -67,12 +69,22 @@ const getTotalAndLastUpdatedAt = async ( const getRecent = async (organism: string, numberDaysAgo: number): Promise => { const recentTimestamp = Math.floor(Date.now() / 1000 - numberDaysAgo * 24 * 60 * 60); const client = LapisClient.createForOrganism(organism); - return ( + const recentTotal = ( + await client.call('aggregated', { + [`${RELEASED_AT_FIELD}From`]: recentTimestamp, + version: 1, + }) + ) + .map((x) => x.data[0].count) + .unwrapOr(0); + const recentRevoked = ( await client.call('aggregated', { [`${RELEASED_AT_FIELD}From`]: recentTimestamp, version: 1, + [VERSION_STATUS_FIELD]: siloVersionStatuses.revoked, }) ) .map((x) => x.data[0].count) .unwrapOr(0); + return recentTotal - recentRevoked; };