diff --git a/src/utils/index.ts b/src/utils/index.ts index 117c1fbc..943d631b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -131,4 +131,13 @@ const handleDateTimeInput = (dateTimeValue: any) => { return DateTime.fromISO(dateTime).toMillis() } -export { handleDateTimeInput, showToast, hasError , parseCsv , jsonToCsv, JsonToCsvOption, isFutureDate } +const prepareRuntime = (job: any) => { + // For job frequency everyday, set to start of next day + // It is not recommended to schedule all jobs at the start of the day as it will cause performance issues if too many jobs scheduled at the same time, + // understanding the risk and assuming that only limited jobs will be scheduled, we are moving ahead as per the recommendation of Aditya P. + if (job.jobStatus === 'EVERYDAY') { + return DateTime.now().startOf('day').plus({days: 1}).toMillis(); + } +} + +export { handleDateTimeInput, showToast, hasError , parseCsv , jsonToCsv, JsonToCsvOption, isFutureDate, prepareRuntime } diff --git a/src/views/Inventory.vue b/src/views/Inventory.vue index 646067a3..a41b4a58 100644 --- a/src/views/Inventory.vue +++ b/src/views/Inventory.vue @@ -62,7 +62,7 @@ import { import { defineComponent } from 'vue'; import { mapGetters, useStore } from 'vuex'; import JobConfiguration from '@/components/JobConfiguration.vue' -import { isFutureDate, showToast } from '@/utils'; +import { isFutureDate, showToast, prepareRuntime } from '@/utils'; import emitter from '@/event-bus'; import { useRouter } from 'vue-router' import { translate } from '@/i18n'; @@ -135,6 +135,7 @@ export default defineComponent({ if (!checked) { this.store.dispatch('job/cancelJob', job) } else if (job?.status === 'SERVICE_DRAFT') { + job.runTime = prepareRuntime(job) this.store.dispatch('job/scheduleService', job) } else if (job?.status === 'SERVICE_PENDING') { this.store.dispatch('job/updateJob', job) diff --git a/src/views/Orders.vue b/src/views/Orders.vue index ea255b55..26ffddea 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -184,7 +184,7 @@ import { useRouter } from 'vue-router' import { mapGetters } from "vuex"; import JobConfiguration from '@/components/JobConfiguration.vue'; import { DateTime } from 'luxon'; -import { hasError, isFutureDate, showToast } from '@/utils'; +import { hasError, isFutureDate, showToast, prepareRuntime } from '@/utils'; import emitter from '@/event-bus'; export default defineComponent({ @@ -366,6 +366,7 @@ export default defineComponent({ if (!checked) { this.store.dispatch('job/cancelJob', job) } else if (job?.status === 'SERVICE_DRAFT') { + job.runTime = prepareRuntime(job) this.store.dispatch('job/scheduleService', job) } else if (job?.status === 'SERVICE_PENDING') { this.store.dispatch('job/updateJob', job) diff --git a/src/views/PreOrder.vue b/src/views/PreOrder.vue index 0f7d888b..fde6727e 100644 --- a/src/views/PreOrder.vue +++ b/src/views/PreOrder.vue @@ -142,7 +142,7 @@ import { mapGetters } from "vuex"; import { useRouter } from 'vue-router' import { alertController } from '@ionic/vue'; import JobConfiguration from '@/components/JobConfiguration.vue' -import { isFutureDate, showToast } from '@/utils'; +import { isFutureDate, showToast, prepareRuntime } from '@/utils'; import emitter from '@/event-bus'; import { translate } from '@/i18n'; @@ -263,6 +263,7 @@ export default defineComponent({ if (!checked) { this.store.dispatch('job/cancelJob', job) } else if (job?.status === 'SERVICE_DRAFT') { + job.runTime = prepareRuntime(job) this.store.dispatch('job/scheduleService', job) } else if (job?.status === 'SERVICE_PENDING') { this.store.dispatch('job/updateJob', job)