Skip to content

Commit

Permalink
feat: add banner informing about data feed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoran-chen committed Jan 12, 2025
1 parent 9372a61 commit 5347d56
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/data/api-lapis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function checkSiloAvailability(signal?: AbortSignal): Promise<SiloA
return { isAvailable: false, retryAfterInSeconds: Number(retryAfterInSeconds) };
}

export async function fetchLapisDataVersion(signal?: AbortSignal): Promise<string> {
export async function fetchLapisDataVersion(signal?: AbortSignal): Promise<number> {
let url = '/info';
if (ACCESS_KEY) {
url += '?accessKey=' + ACCESS_KEY;
Expand All @@ -92,8 +92,7 @@ export async function fetchLapisDataVersion(signal?: AbortSignal): Promise<strin
throw new Error('Error fetching info');
}
const info = (await response.json()) as LapisInformation;
currentLapisDataVersion = Number(info.dataVersion);
return dayjs.unix(currentLapisDataVersion).locale('en').calendar();
return Number(info.dataVersion);
}

export async function fetchNextcladeDatasetInfo(signal?: AbortSignal): Promise<NextcladeDatasetInfo> {
Expand Down
9 changes: 7 additions & 2 deletions src/layout/base/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { sequenceDataSource } from '../../helpers/sequence-data-source';
import { ExternalLink } from '../../components/ExternalLink';
import React from 'react';
import styled from 'styled-components';
import dayjs from 'dayjs';

const FooterStyle = styled.footer`
margin-top: 50px;
Expand All @@ -16,11 +17,15 @@ export function Footer({
lapisDataVersion,
}: {
nextcladeDatasetInfo?: NextcladeDatasetInfo;
lapisDataVersion?: string;
lapisDataVersion?: number;
}) {
let lapisUpdateFormattedString = '';
if (lapisDataVersion !== undefined) {
lapisUpdateFormattedString = dayjs.unix(lapisDataVersion).locale('en').calendar();
}
return (
<FooterStyle className='text-center'>
{lapisDataVersion && <div>The sequence data was updated: {lapisDataVersion}</div>}
{lapisUpdateFormattedString && <div>The sequence data was updated: {lapisUpdateFormattedString}</div>}
{nextcladeDatasetInfo?.tag && <div>Nextclade dataset version: {nextcladeDatasetInfo.tag}</div>}
{sequenceDataSource === 'gisaid' && (
<div>
Expand Down
33 changes: 33 additions & 0 deletions src/pages/ExplorePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { useSingleSelectorsFromExploreUrl } from '../helpers/selectors-from-expl
import { InternalLink } from '../components/InternalLink';
import { MdOutlineOpenInNew } from 'react-icons/md';
import { Link } from 'react-router-dom';
import { sequenceDataSource } from '../helpers/sequence-data-source';
import { fetchLapisDataVersion } from '../data/api-lapis';

type Props = {
isSmallScreen: boolean;
Expand Down Expand Up @@ -54,6 +56,7 @@ export const ExplorePage = ({ isSmallScreen }: Props) => {

return (
<div className={`w-full mx-auto max-w-6xl mt-4`}>
<MissingDataUpdateBanner />
<GenspectrumBanner />
<div className='p-2 mr-4 '>
<h1>Detect and analyze variants of SARS-CoV-2</h1>
Expand Down Expand Up @@ -100,6 +103,36 @@ export const ExplorePage = ({ isSmallScreen }: Props) => {
);
};

function MissingDataUpdateBanner() {
const { data: lapisDataVersion } = useQuery(fetchLapisDataVersion, []);
console.log(lapisDataVersion);
if (sequenceDataSource === 'gisaid' && lapisDataVersion === 1734968364) {
return (
<div className='w-full bg-yellow-100 shadow-lg mt-4 rounded-xl p-4 dark:bg-gray-800 mx-2 mr-4'>
<h2>Data feed interruption</h2>
<p>
Data on this dashboard has not been updated since{' '}
<span className='font-bold'>23 December 2024</span> due to an interruption in the data feed. We have
contacted the data provider GISAID regarding this issue and hope for a resolution soon. In the
meantime, you can check out the{' '}
<Link to='https://open.cov-spectrum.org' className='text-active-secondary'>
Open instance of CoV-Spectrum
</Link>{' '}
or the new{' '}
<Link to={'https://genspectrum.org/'} className={'text-active-secondary'}>
<span className='inline-flex gap-1 items-center'>
GenSpectrum dashboard
<MdOutlineOpenInNew />
</span>
</Link>{' '}
for more recent data from INSDC.
</p>
</div>
);
}
return <></>;
}

function GenspectrumBanner() {
return (
<div className='w-full bg-blue-50 shadow-lg mt-4 rounded-xl p-4 dark:bg-gray-800 mx-2 mr-4'>
Expand Down

0 comments on commit 5347d56

Please sign in to comment.