Skip to content

Commit

Permalink
Merge pull request #131 from ymaheshwari1/#130
Browse files Browse the repository at this point in the history
Fixed: the schedule time and timeDiff as the execution time has been changed from seconds to millis(#130)
  • Loading branch information
ymaheshwari1 authored Feb 27, 2024
2 parents bd15d3f + a5ba0ec commit baad44f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ const getTime = (time: any) => {
return time ? DateTime.fromMillis(time).toLocaleString(DateTime.TIME_SIMPLE) : "-";
}

const getTimeFromSeconds = (time: any) => {
return time ? DateTime.fromSeconds(time).toLocaleString(DateTime.DATETIME_MED) : "-";
}

function getDate(runTime: any) {
return DateTime.fromMillis(runTime).toLocaleString(DateTime.DATE_MED);
}
Expand All @@ -59,4 +55,4 @@ function timeTillRun(endTime: any) {
return DateTime.local().plus(timeDiff).toRelative();
}

export { getDate, getDateAndTime, getDateAndTimeShort, getTime, getTimeFromSeconds, showToast, hasError, sortSequence, timeTillRun }
export { getDate, getDateAndTime, getDateAndTimeShort, getTime, showToast, hasError, sortSequence, timeTillRun }
10 changes: 5 additions & 5 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<ion-item lines="none">
<h2>{{ translate("Scheduler") }}</h2>
<!-- When the group is in draft status, do not display the time delta badge -->
<ion-badge slot="end" v-if="job.paused === 'N'">{{ timeTillJobUsingSeconds(job.nextExecutionDateTime) }}</ion-badge>
<ion-badge slot="end" v-if="job.paused === 'N'">{{ timeTillJob(job.nextExecutionDateTime) }}</ion-badge>
</ion-item>
<ion-item v-show="typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" lines="none">
<ion-label color="danger" class="ion-text-wrap">
Expand All @@ -108,7 +108,7 @@
<ion-icon slot="start" :icon="timeOutline"/>
<ion-label>{{ translate("Run time") }}</ion-label>
<!-- When the group is in draft status, do not display the runTime from the schedule -->
<ion-label slot="end">{{ job.paused === 'N' ? getTimeFromSeconds(job.nextExecutionDateTime) : "-" }}</ion-label>
<ion-label slot="end">{{ job.paused === 'N' ? getDateAndTime(job.nextExecutionDateTime) : "-" }}</ion-label>
</ion-item>
<ion-item lines="none">
<ion-icon slot="start" :icon="timerOutline"/>
Expand Down Expand Up @@ -155,7 +155,7 @@ import ArchivedRoutingModal from "@/components/ArchivedRoutingModal.vue"
import { OrderRoutingService } from "@/services/RoutingService";
import logger from "@/logger";
import { DateTime } from "luxon";
import { hasError, getDate, getDateAndTime, getDateAndTimeShort, getTime, getTimeFromSeconds, showToast, sortSequence, timeTillRun } from "@/utils";
import { hasError, getDate, getDateAndTime, getDateAndTimeShort, getTime, showToast, sortSequence, timeTillRun } from "@/utils";
import emitter from "@/event-bus";
import { translate } from "@/i18n";
import GroupHistoryModal from "@/components/GroupHistoryModal.vue"
Expand Down Expand Up @@ -316,11 +316,11 @@ async function saveSchedule() {
}
}
function timeTillJobUsingSeconds(time: any) {
function timeTillJob(time: any) {
if(!time) {
return;
}
const timeDiff = DateTime.fromSeconds(time).diff(DateTime.local());
const timeDiff = DateTime.fromMillis(time).diff(DateTime.local());
return DateTime.local().plus(timeDiff).toRelative();
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/BrokeringRuns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
</ion-item>
<ion-item v-if="group.schedule?.paused === 'N'">
<ion-label>
{{ group.schedule ? getTimeFromSeconds(group.schedule.nextExecutionDateTime) : "-" }}
{{ group.schedule ? getDateAndTime(group.schedule.nextExecutionDateTime) : "-" }}
<p>{{ group.schedule ? getScheduleFrequency(group.schedule.cronExpression) : "-" }}</p>
</ion-label>
<ion-badge slot="end" color="dark">
{{ group.schedule ? timeTillRunUsingSeconds(group.schedule.nextExecutionDateTime) : "-" }}
{{ group.schedule ? timeTillRun(group.schedule.nextExecutionDateTime) : "-" }}
</ion-badge>
</ion-item>
<ion-item v-else>
<!-- TODO: display lastRunTime, but as we are not getting the same in response, so displaying nextExecutionTime for now -->
<ion-label>
{{ group.schedule ? getTimeFromSeconds(group.schedule.nextExecutionDateTime) : "-" }}
{{ group.schedule ? getDateAndTime(group.schedule.nextExecutionDateTime) : "-" }}
</ion-label>
<ion-badge slot="end" color="dark">{{ translate("Draft") }}</ion-badge>
</ion-item>
Expand All @@ -82,7 +82,7 @@
import emitter from "@/event-bus";
import { translate } from "@/i18n";
import { Group } from "@/types";
import { getDateAndTime, getTimeFromSeconds, showToast } from "@/utils";
import { getDateAndTime, showToast } from "@/utils";
import { IonBadge, IonButton, IonButtons, IonCard, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonPage, IonRadioGroup, IonRadio, IonSearchbar, IonSpinner, IonTitle, IonToolbar, alertController, onIonViewWillEnter } from "@ionic/vue";
import { addOutline } from "ionicons/icons"
import { DateTime } from "luxon";
Expand Down Expand Up @@ -110,8 +110,8 @@ onIonViewWillEnter(async () => {
store.dispatch("util/fetchEnums", { parentTypeId: "ORDER_ROUTING" })
})
function timeTillRunUsingSeconds(time: any) {
const timeDiff = DateTime.fromSeconds(time).diff(DateTime.local());
function timeTillRun(time: any) {
const timeDiff = DateTime.fromMillis(time).diff(DateTime.local());
return DateTime.local().plus(timeDiff).toRelative();
}
Expand Down

0 comments on commit baad44f

Please sign in to comment.