Skip to content

Commit

Permalink
Merge pull request #225 from disha1202/#2ftb2vw
Browse files Browse the repository at this point in the history
Improved: runTime set to start of the next day for 'EVERYDAY' frequency(#2ftb2vw)
  • Loading branch information
adityasharma7 authored Aug 26, 2022
2 parents 2eed7e1 + e5fb077 commit 8e134cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
3 changes: 2 additions & 1 deletion src/views/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,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';
import { JobService } from '@/services/JobService'
Expand Down Expand Up @@ -394,6 +394,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)
Expand Down
3 changes: 2 additions & 1 deletion src/views/PreOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e134cb

Please sign in to comment.