From 21ff94edd6fff7dbc27ae4de840c4758f17b904d Mon Sep 17 00:00:00 2001 From: prashant singh rathore Date: Fri, 29 Jul 2022 17:07:11 +0530 Subject: [PATCH 1/7] Improved: updateRuntime method to set the start of next day(#2ftb2vw) For job frequency everyday, set to start of next day and remove set runtime for other job-frequency it take the server time for now --- src/utils/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 6151f903..7ce46630 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -132,10 +132,9 @@ const handleDateTimeInput = (dateTimeValue: any) => { } const prepareRuntime = (job: any) => { + // For job frequency everyday, set to start of next day if (job.frequency === 'EVERYDAY') { - return DateTime.now().startOf('day').toMillis() - } else { - return DateTime.now().toMillis() + return DateTime.now().startOf('day').toMillis() + 86400000; } } From c58bc2bf6f0b9e869740d9de0df6edd3f80c0761 Mon Sep 17 00:00:00 2001 From: prashant singh rathore Date: Fri, 29 Jul 2022 18:34:30 +0530 Subject: [PATCH 2/7] Implemented: code to update job runtime by prepareRuntime method(#2ftb2vw) --- src/views/Inventory.vue | 3 ++- src/views/Orders.vue | 3 ++- src/views/PreOrder.vue | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) 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) From c04ec9968c6e7482e94c50205587c932c5b5492b Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Mon, 22 Aug 2022 15:10:24 +0530 Subject: [PATCH 3/7] Updated the prepareRuntime method to use plus to add 1 day(#2ftb2vw) --- src/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 7ce46630..ca824db4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -134,7 +134,7 @@ const handleDateTimeInput = (dateTimeValue: any) => { const prepareRuntime = (job: any) => { // For job frequency everyday, set to start of next day if (job.frequency === 'EVERYDAY') { - return DateTime.now().startOf('day').toMillis() + 86400000; + return DateTime.now().startOf('day').plus({days: 1}); } } From 1631cbac9c9cad0f1c42b4e715558c57d056f937 Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Tue, 23 Aug 2022 12:54:39 +0530 Subject: [PATCH 4/7] Updated prepareRuntime method to return timestamp and updated condition to verify whether the job is to be scheduled everyday(#2ftb2vw) --- src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index ca824db4..68cb0c60 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -133,8 +133,8 @@ const handleDateTimeInput = (dateTimeValue: any) => { const prepareRuntime = (job: any) => { // For job frequency everyday, set to start of next day - if (job.frequency === 'EVERYDAY') { - return DateTime.now().startOf('day').plus({days: 1}); + if (job.jobStatus === 'EVERYDAY') { + return DateTime.now().startOf('day').plus({days: 1}).toMillis(); } } From 0cc3ea2b798f6f74c8e771e43fbdb2240799c796 Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Fri, 26 Aug 2022 15:17:56 +0530 Subject: [PATCH 5/7] Added comment(#2ftb2vw) --- src/utils/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/index.ts b/src/utils/index.ts index 68cb0c60..9abccc50 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -133,6 +133,8 @@ const handleDateTimeInput = (dateTimeValue: any) => { 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 decrease performance if too many jobs scheduled at the same time, + // but we're assuming that we'll have only few jobs with frequency 'EVERYDAY' if (job.jobStatus === 'EVERYDAY') { return DateTime.now().startOf('day').plus({days: 1}).toMillis(); } From 725acb121e4b5db84021b90ef831cd51e8780533 Mon Sep 17 00:00:00 2001 From: Aditya Sharma Date: Fri, 26 Aug 2022 15:32:31 +0530 Subject: [PATCH 6/7] Improved comments --- src/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 9abccc50..b8f340ea 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -133,7 +133,7 @@ const handleDateTimeInput = (dateTimeValue: any) => { 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 decrease performance if too many jobs scheduled at the same time, + // 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, // but we're assuming that we'll have only few jobs with frequency 'EVERYDAY' if (job.jobStatus === 'EVERYDAY') { return DateTime.now().startOf('day').plus({days: 1}).toMillis(); From e5fb07764848c6e626dfb84c83a96b9141269f08 Mon Sep 17 00:00:00 2001 From: Aditya Sharma Date: Fri, 26 Aug 2022 15:32:41 +0530 Subject: [PATCH 7/7] Improved comments --- src/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index b8f340ea..943d631b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -134,7 +134,7 @@ const handleDateTimeInput = (dateTimeValue: any) => { 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, - // but we're assuming that we'll have only few jobs with frequency 'EVERYDAY' + // 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(); }