Skip to content

Commit

Permalink
Merge pull request #3788 from alephdata/feature/status-page-timestamps
Browse files Browse the repository at this point in the history
Display start and last updated timestamp on system status page
  • Loading branch information
stchris authored Jul 19, 2024
2 parents 8387d24 + 395a382 commit f220131
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 11 deletions.
3 changes: 1 addition & 2 deletions aleph/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Dict, Callable

import structlog
from servicelayer.taskqueue import Worker, Task, Dataset
from servicelayer.taskqueue import Worker, Task
from servicelayer import settings as sls

from aleph import __version__
Expand Down Expand Up @@ -138,7 +138,6 @@ def periodic(self):
self.often.update()
log.info("Self-check...")
compute_collections()
Dataset.cleanup_dataset_status(kv)

if self.daily.check():
self.daily.update()
Expand Down
79 changes: 70 additions & 9 deletions ui/src/screens/SystemStatusScreen/SystemStatusScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
import {
defineMessages,
FormattedDate,
FormattedMessage,
FormattedTime,
injectIntl,
} from 'react-intl';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Button, ProgressBar, Intent } from '@blueprintjs/core';
Expand All @@ -12,9 +18,19 @@ import Dashboard from 'components/Dashboard/Dashboard';
import ErrorScreen from 'components/Screen/ErrorScreen';
import { triggerCollectionCancel, fetchSystemStatus } from 'actions';
import { selectSystemStatus } from 'selectors';
import convertUTCDateToLocalDate from 'util/convertUTCDateToLocalDate';

import './SystemStatusScreen.scss';

const dateFormat = {
year: 'numeric',
month: 'short',
day: 'numeric',
weekday: 'short',
hour: 'numeric',
minute: 'numeric',
};

const messages = defineMessages({
title: {
id: 'dashboard.title',
Expand Down Expand Up @@ -100,16 +116,61 @@ export class SystemStatusScreen extends React.Component {
const active = res.pending + res.running;
const total = active + res.finished;
const progress = res.finished / total;

const startedAt =
res.start_time && convertUTCDateToLocalDate(res.start_time);
const lastUpdatedAt =
res.last_update && convertUTCDateToLocalDate(res.last_update);
const today = new Date();

return (
<tr key={collection?.id || 'null'}>
<td className="entity">
<Collection.Link collection={res.collection} />
{!res.collection && (
<FormattedMessage
id="status.no_collection"
defaultMessage="Other tasks"
/>
)}
<td>
<strong>
<Collection.Link collection={res.collection} />
{!res.collection && (
<FormattedMessage
id="status.no_collection"
defaultMessage="Other tasks"
/>
)}
</strong>
<br />
<span className="StatusTable__timestamps">
{startedAt && (
<>
<FormattedMessage
id="status.started_at"
defaultMessage="started"
/>{' '}
<span title={intl.formatDate(startedAt, dateFormat)}>
{today.toDateString() !== startedAt.toDateString() && (
<>
<FormattedDate value={startedAt} />{' '}
</>
)}
<FormattedTime value={startedAt} />
</span>
</>
)}
{lastUpdatedAt && (
<>
{' · '}
<FormattedMessage
id="status.last_updated_at"
defaultMessage="last updated"
/>{' '}
<span title={intl.formatDate(lastUpdatedAt, dateFormat)}>
{today.toDateString() !== lastUpdatedAt.toDateString() && (
<>
<FormattedDate value={lastUpdatedAt} />{' '}
</>
)}
<FormattedTime value={lastUpdatedAt} />
</span>
</>
)}
</span>
</td>
<td>
<ProgressBar value={progress} intent={Intent.PRIMARY} />
Expand Down
4 changes: 4 additions & 0 deletions ui/src/screens/SystemStatusScreen/SystemStatusScreen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
td.text {
@include rtlSupportInvertedProp(padding, left, 0, null);
}

&__timestamps {
color: $aleph-greyed-text;
}
}

0 comments on commit f220131

Please sign in to comment.