Skip to content

Commit

Permalink
fix(app): fix timestamp used for protocol completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Nov 15, 2024
1 parent df80263 commit e0047a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export function ProtocolWithLastRun({
}
// TODO(BC, 2023-06-05): see if addSuffix false allow can remove usage of .replace here
const formattedLastRunTime = formatDistance(
new Date(runData.createdAt),
// Fallback to current date if completedAt is null, though this should never happen since runs must be completed to appear in dashboard
new Date(runData.completedAt ?? new Date()),
new Date(),
{
addSuffix: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const missingBoth = [
const mockRunData = {
id: RUN_ID,
createdAt: '2022-05-03T21:36:12.494778+00:00',
completedAt: 'thistime',
completedAt: '2023-05-03T21:36:12.494778+00:00',
startedAt: 'thistime',
protocolId: 'mockProtocolId',
status: RUN_STATUS_FAILED,
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('RecentRunProtocolCard', () => {
it('should render text', () => {
render(props)
const lastRunTime = formatDistance(
new Date(mockRunData.createdAt),
new Date(mockRunData.completedAt),
new Date(),
{
addSuffix: true,
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/ODD/ProtocolDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export function ProtocolDashboard(): JSX.Element {
{sortedProtocols.map(protocol => {
const lastRun = runs.data?.data.find(
run => run.protocolId === protocol.id
)?.createdAt
)?.completedAt

return (
<ProtocolCard
Expand Down

0 comments on commit e0047a5

Please sign in to comment.