From ee18a174d1a373f692006920077d5b6e11741059 Mon Sep 17 00:00:00 2001 From: Jay <159848059+jayacryl@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:56:56 -0400 Subject: [PATCH] fix(data-contracts-web) handle other schedule types (#10919) --- .../contract/FreshnessScheduleSummary.tsx | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/datahub-web-react/src/app/entity/shared/tabs/Dataset/Validations/contract/FreshnessScheduleSummary.tsx b/datahub-web-react/src/app/entity/shared/tabs/Dataset/Validations/contract/FreshnessScheduleSummary.tsx index 434ccb985574f..5009587c0d277 100644 --- a/datahub-web-react/src/app/entity/shared/tabs/Dataset/Validations/contract/FreshnessScheduleSummary.tsx +++ b/datahub-web-react/src/app/entity/shared/tabs/Dataset/Validations/contract/FreshnessScheduleSummary.tsx @@ -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}; };