Skip to content

Commit

Permalink
Improved: code for default runtime for new job and skip job not worki…
Browse files Browse the repository at this point in the history
…ng (#620)
  • Loading branch information
amansinghbais committed Oct 30, 2023
1 parent d57851f commit 6e19f00
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
17 changes: 7 additions & 10 deletions src/components/BatchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ion-label>{{ $t('More parameters') }}</ion-label>
</ion-item>

<ion-item-divider v-if="customRequiredParameters.length">
<ion-item-divider v-if="customRequiredParameters.length" color="light">
<ion-label>{{ $t('Required Parameters') }}</ion-label>
</ion-item-divider>

Expand Down Expand Up @@ -66,7 +66,7 @@
<ion-card-title>{{ $t('Schedule') }}</ion-card-title>
</ion-card-header>

<ion-item :disabled="currentBatch?.jobId">
<ion-item>
<ion-icon slot="start" :icon="timeOutline" />
<ion-label>{{ $t('Run time') }}</ion-label>
<ion-select interface="popover" :placeholder="$t('Select')" :value="runTime" @ionChange="updateRunTime($event)">
Expand All @@ -84,7 +84,7 @@
</ion-content>
</ion-modal>
</ion-item>
<ion-item lines="none" :disabled="currentBatch?.jobId">
<ion-item lines="none">
<ion-icon slot="start" :icon="timerOutline" />
<ion-label>{{ $t('Frequency') }}</ion-label>
<ion-select :value="jobStatus" :interface-options="{ header: $t('Frequency') }" interface="popover" :placeholder="$t('Disabled')" @ionChange="jobStatus = $event.detail.value" @ionDismiss="jobStatus == 'CUSTOM' && setCustomFrequency()">
Expand Down Expand Up @@ -226,9 +226,7 @@ export default defineComponent({
this.jobStatus = currentFrequency;
},
async updateJob() {
const jobEnum: any = Object.values(this.jobEnums)?.find((job: any) => {
return job.unfillable === this.unfillableOrder && job.facilityId === this.batchFacilityId
});
const jobEnum: any = Object.values(this.jobEnums)?.find((job: any) => job.unfillable === this.unfillableOrder && job.facilityId === this.batchFacilityId);
const job = this.getJob(jobEnum.id)?.find((job: any) => job.status === 'SERVICE_DRAFT');
if (!job) {
Expand All @@ -246,10 +244,11 @@ export default defineComponent({
job.runTime = ''
}
job['jobStatus'] = this.jobStatus !== 'SERVICE_DRAFT' ? this.jobStatus : 'HOURLY';
job['jobStatus'] = this.jobStatus ? this.jobStatus : 'HOURLY';
job['jobName'] = this.jobName || this.currentDateTime;
const jobCustomParameters = generateJobCustomParameters(this.customRequiredParameters, this.customOptionalParameters, job.runtimeData)
await this.store.dispatch('job/scheduleService', { job, jobCustomParameters })
this.closeModal()
},
Expand All @@ -271,9 +270,7 @@ export default defineComponent({
else showToast(translate("Provide a future date and time"))
},
updateCustomParameters() {
const jobEnum: any = Object.values(this.jobEnums)?.find((job: any) => {
return job.unfillable === this.unfillableOrder && job.facilityId === this.batchFacilityId
});
const jobEnum: any = Object.values(this.jobEnums)?.find((job: any) => job.unfillable === this.unfillableOrder && job.facilityId === this.batchFacilityId);
const job = this.getJob(jobEnum.id)?.find((job: any) => job.status === 'SERVICE_DRAFT');
this.customOptionalParameters = generateJobCustomOptions(job).optionalParameters;
Expand Down
18 changes: 17 additions & 1 deletion src/store/modules/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,23 @@ const actions: ActionTree<JobState, RootState> = {
});

// fetching temp expressions
const tempExpr = Object.values(cached).map((job: any) => job.tempExprId)
// added check to loop over cachedJob (in else part), as in case of batch job same enum contains multiple jobs as an array
// and thus tempExprId is not available by default on the root
// Before looping over cachedJob, checking whether the tempExprId is directly available on the root or not,
// if tempExprId is available on root it simply means that we have a single job against the enum
const tempExpr = Object.values(cached).reduce((tempExprIds: any, cachedJob: any) => {
if(cachedJob.tempExprId && !tempExprIds.includes(cachedJob.tempExprId)) {
tempExprIds.push(cachedJob.tempExprId)
} else if (cachedJob?.length) {
cachedJob.map((job: any) => {
if(job.tempExprId && !tempExprIds.includes(job.tempExprId)) {
tempExprIds.push(job.tempExprId)
}
});
}

return tempExprIds;
}, [])
await dispatch('fetchTemporalExpression', tempExpr)

commit(types.JOB_UPDATED_BULK, cached);
Expand Down
24 changes: 11 additions & 13 deletions src/views/Brokering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<ion-list>
<ion-item lines="none">
<ion-label class="ion-text-wrap">{{ batch?.temporalExpression?.description }}</ion-label>
<ion-label slot="end">{{ batch?.runTime ? getTime(batch.runTime) : "-" }}</ion-label>
<ion-label slot="end">{{ batch?.runTime ? getTime(batch.runTime) : "-" }}</ion-label>
</ion-item>

<ion-item lines="none">
Expand All @@ -58,7 +58,7 @@
</section>

<aside class="desktop-only" v-if="isDesktop" v-show="currentJob">
<JobConfiguration :type="freqType" :key="currentJob" isBrokerJob="true"/>
<JobConfiguration :status="currentJobStatus" :type="freqType" :key="currentJob" isBrokerJob="true"/>
</aside>
</main>
</ion-content>
Expand Down Expand Up @@ -163,21 +163,19 @@ export default defineComponent({
return DateTime.fromMillis(time).toFormat('hh:mm a');
},
getBrokerQueue(job: any){
if(job.status === 'SERVICE_PENDING'){
const brokerQueueId = this.batchJobEnums[job?.enumId].id
if(brokerQueueId === "_NA_"){
return "Brokering queue"
}else if(brokerQueueId === "PRE_ORDER_PARKING"){
return "Pre-order parking"
}else{
return "Back-order parking"
}
const brokerQueueId = this.batchJobEnums[job?.enumId].facilityId
if(brokerQueueId === "_NA_"){
return "Brokering queue"
}else if(brokerQueueId === "PRE_ORDER_PARKING"){
return "Pre-order parking"
}else{
return "Back-order parking"
}
},
async viewJobConfiguration(jobInformation: any) {
this.currentJob = jobInformation.job || this.getJob(this.jobEnums[jobInformation.id])
this.currentJobStatus = jobInformation.status
this.currentJobStatus = this.currentJob.statusId === 'SERVICE_DRAFT' ? 'SERVICE_DRAFT' : this.currentJob.frequency
this.freqType = jobInformation.id && this.jobFrequencyType[jobInformation.id]
// if job runTime is not a valid date then making runTime as empty
Expand Down

0 comments on commit 6e19f00

Please sign in to comment.