Skip to content

Commit

Permalink
fix(data-contracts-web) handle other schedule types (#10919)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayacryl committed Jul 16, 2024
1 parent ea2216a commit ee18a17
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,29 @@ type Props = {
};

export const FreshnessScheduleSummary = ({ definition, evaluationSchedule }: Props) => {
const scheduleText =
definition.type === FreshnessAssertionScheduleType.Cron
? `${capitalizeFirstLetter(cronstrue.toString(definition.cron?.cron as string))}.`
: `In the past ${
definition.fixedInterval?.multiple
} ${definition.fixedInterval?.unit.toLocaleLowerCase()}s${
(evaluationSchedule &&
`, as of ${cronstrue.toString(evaluationSchedule.cron as string).toLowerCase()}`) ||
''
}`;
let scheduleText = '';
const cronStr = definition.cron?.cron ?? evaluationSchedule?.cron;
switch (definition.type) {
case FreshnessAssertionScheduleType.Cron:
scheduleText = cronStr
? `${capitalizeFirstLetter(cronstrue.toString(cronStr))}.`
: `Unknown freshness schedule.`;
break;
case FreshnessAssertionScheduleType.SinceTheLastCheck:
scheduleText = cronStr
? `Since the previous check, as of ${cronstrue.toString(cronStr).toLowerCase()}`
: 'Since the previous check';
break;
case FreshnessAssertionScheduleType.FixedInterval:
scheduleText = `In the past ${
definition.fixedInterval?.multiple
} ${definition.fixedInterval?.unit.toLocaleLowerCase()}s${
cronStr ? `, as of ${cronstrue.toString(cronStr).toLowerCase()}` : ''
}`;
break;
default:
break;
}

return <>{scheduleText}</>;
};

0 comments on commit ee18a17

Please sign in to comment.