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

refactor(website): rename siloVersionStatus to versionStatus #2818

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 7 additions & 6 deletions website/src/components/IndexPage/getOrganismStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { DateTime, FixedOffsetZone } from 'luxon';

import { LapisClient } from '../../services/lapisClient.ts';
import { RELEASED_AT_FIELD, VERSION_STATUS_FIELD, IS_REVOCATION_FIELD } from '../../settings.ts';
import { siloVersionStatuses } from '../../types/lapis';
import { versionStatuses } from '../../types/lapis';

// Excluding sequences whose latest version is revoked
corneliusroemer marked this conversation as resolved.
Show resolved Hide resolved
export type OrganismStatistics = {
totalSequences: number;
recentSequences: number;
Expand Down Expand Up @@ -50,7 +51,7 @@ const getTotalAndLastUpdatedAt = async (
const client = LapisClient.createForOrganism(organism);
return (
await client.call('aggregated', {
[VERSION_STATUS_FIELD]: siloVersionStatuses.latestVersion,
[VERSION_STATUS_FIELD]: versionStatuses.latestVersion,
[IS_REVOCATION_FIELD]: 'false',
})
)
Expand All @@ -69,22 +70,22 @@ const getTotalAndLastUpdatedAt = async (
const getRecent = async (organism: string, numberDaysAgo: number): Promise<number> => {
const recentTimestamp = Math.floor(Date.now() / 1000 - numberDaysAgo * 24 * 60 * 60);
const client = LapisClient.createForOrganism(organism);
const recentTotal = (
const recentTotalIncludingRevoked = (
await client.call('aggregated', {
[`${RELEASED_AT_FIELD}From`]: recentTimestamp,
version: 1,
})
)
.map((x) => x.data[0].count)
.unwrapOr(0);
const recentRevoked = (
const recentTotalRevoked = (
await client.call('aggregated', {
[`${RELEASED_AT_FIELD}From`]: recentTimestamp,
version: 1,
[VERSION_STATUS_FIELD]: siloVersionStatuses.revoked,
[VERSION_STATUS_FIELD]: versionStatuses.revoked,
corneliusroemer marked this conversation as resolved.
Show resolved Hide resolved
})
)
.map((x) => x.data[0].count)
.unwrapOr(0);
return recentTotal - recentRevoked;
return recentTotalIncludingRevoked - recentTotalRevoked;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IS_REVOCATION_FIELD, metadataDefaultDownloadDataFormat, VERSION_STATUS_FIELD } from '../../../settings.ts';
import { siloVersionStatuses } from '../../../types/lapis.ts';
import { versionStatuses } from '../../../types/lapis.ts';

export type DownloadDataType =
| { type: 'metadata' }
Expand All @@ -26,7 +26,7 @@ export const generateDownloadUrl = (

params.set('downloadAsFile', 'true');
if (!option.includeOldData) {
params.set(VERSION_STATUS_FIELD, siloVersionStatuses.latestVersion);
params.set(VERSION_STATUS_FIELD, versionStatuses.latestVersion);
params.set(IS_REVOCATION_FIELD, 'false');
}
if (!option.includeRestricted) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { getLatestAccessionVersion } from './getTableData';
import { routes } from '../../routes/routes.ts';
import { type SequenceEntryHistory, siloVersionStatuses } from '../../types/lapis';
import { type SequenceEntryHistory, versionStatuses } from '../../types/lapis';
import { getAccessionVersionString } from '../../utils/extractAccessionVersion';

interface Props {
Expand All @@ -16,8 +16,8 @@ const ownHistoryEntry = sequenceEntryHistory.find((entry) => entry.accessionVers
const latestAccessionVersion = getLatestAccessionVersion(sequenceEntryHistory);

const revoked =
ownHistoryEntry?.versionStatus === siloVersionStatuses.revoked && latestAccessionVersion?.isRevocation === true;
const isLatestVersion = ownHistoryEntry?.versionStatus === siloVersionStatuses.latestVersion;
ownHistoryEntry?.versionStatus === versionStatuses.revoked && latestAccessionVersion?.isRevocation === true;
const isLatestVersion = ownHistoryEntry?.versionStatus === versionStatuses.latestVersion;
---

<div class='py-3'>
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/[organism]/search/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { SearchFullUI } from '../../../components/SearchPage/SearchFullUI';
import { getRuntimeConfig, getSchema } from '../../../config';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import { VERSION_STATUS_FIELD, IS_REVOCATION_FIELD } from '../../../settings';
import { siloVersionStatuses } from '../../../types/lapis';
import { versionStatuses } from '../../../types/lapis';
import { getAccessToken } from '../../../utils/getAccessToken';
import { getMyGroups } from '../../../utils/getMyGroups';
import { getReferenceGenomesSequenceNames } from '../../../utils/search';
import { performLapisSearchQueries } from '../../../utils/serversideSearch';

const hiddenFieldValues = {
[VERSION_STATUS_FIELD]: siloVersionStatuses.latestVersion,
[VERSION_STATUS_FIELD]: versionStatuses.latestVersion,
[IS_REVOCATION_FIELD]: 'false',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SearchFullUI } from '../../../../components/SearchPage/SearchFullUI';
import SubmissionPageWrapper from '../../../../components/Submission/SubmissionPageWrapper.astro';
import { getRuntimeConfig, getSchema } from '../../../../config';
import { GROUP_ID_FIELD, VERSION_STATUS_FIELD } from '../../../../settings';
import { siloVersionStatuses } from '../../../../types/lapis';
import { versionStatuses } from '../../../../types/lapis';
import { getAccessToken } from '../../../../utils/getAccessToken';
import { getReferenceGenomesSequenceNames } from '../../../../utils/search';
import { performLapisSearchQueries } from '../../../../utils/serversideSearch';
Expand Down Expand Up @@ -33,7 +33,7 @@ const accessToken = getAccessToken(Astro.locals.session);
const referenceGenomeSequenceNames = getReferenceGenomesSequenceNames(cleanedOrganism.key);

const hiddenFieldValues = {
[VERSION_STATUS_FIELD]: siloVersionStatuses.latestVersion,
[VERSION_STATUS_FIELD]: versionStatuses.latestVersion,
[GROUP_ID_FIELD]: group.groupId,
};

Expand Down
4 changes: 2 additions & 2 deletions website/src/services/lapisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type LapisBaseRequest,
sequenceEntryHistory,
type SequenceEntryHistory,
siloVersionStatuses,
versionStatuses,
} from '../types/lapis.ts';
import type { BaseType } from '../utils/sequenceTypeHelpers.ts';

Expand Down Expand Up @@ -56,7 +56,7 @@ export class LapisClient extends ZodiosWrapperClient<typeof lapisApi> {
public async getLatestAccessionVersion(accession: string): Promise<Result<AccessionVersion, ProblemDetail>> {
const result = await this.call('details', {
accession,
versionStatus: siloVersionStatuses.latestVersion,
versionStatus: versionStatuses.latestVersion,
fields: [ACCESSION_FIELD, VERSION_FIELD],
});

Expand Down
14 changes: 7 additions & 7 deletions website/src/types/lapis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,25 @@ export type LapisError = {
error: ProblemDetail;
};

export const siloVersionStatuses = {
export const versionStatuses = {
revoked: 'REVOKED',
revised: 'REVISED',
latestVersion: 'LATEST_VERSION',
} as const;

export const siloVersionStatusSchema = z.enum([
siloVersionStatuses.revoked,
siloVersionStatuses.revised,
siloVersionStatuses.latestVersion,
export const versionStatusSchema = z.enum([
versionStatuses.revoked,
versionStatuses.revised,
versionStatuses.latestVersion,
]);

export type SiloVersionStatus = z.infer<typeof siloVersionStatusSchema>;
export type VersionStatus = z.infer<typeof versionStatusSchema>;

export const sequenceEntryHistoryEntry = accessionVersion
.merge(
z.object({
accessionVersion: z.string(),
versionStatus: siloVersionStatusSchema,
versionStatus: versionStatusSchema,
isRevocation: z.boolean(),
submittedAtTimestamp: z.number(),
}),
Expand Down
6 changes: 3 additions & 3 deletions website/src/utils/getVersionStatusColor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type SiloVersionStatus, siloVersionStatuses } from '../types/lapis.ts';
import { type VersionStatus, versionStatuses } from '../types/lapis.ts';

export const getVersionStatusColor = (versionStatus: SiloVersionStatus) => {
export const getVersionStatusColor = (versionStatus: VersionStatus) => {
switch (versionStatus) {
case siloVersionStatuses.latestVersion:
case versionStatuses.latestVersion:
return 'text-green-500';
default:
return 'text-red-500';
Expand Down
Loading