Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: runTime set to start of the next day for 'EVERYDAY' frequency(#2ftb2vw) #225

Merged
merged 8 commits into from
Aug 26, 2022
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 @@ -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({
Expand Down Expand Up @@ -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)
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