Skip to content

Commit

Permalink
Improved: logic to run the job successfully on clicking runNow(#147)
Browse files Browse the repository at this point in the history
Clicking runNow when the group does not have a scheduler configured(job is not already scheduled) results in an error.
Improved support to check whether the scheduler is configured for the group or not, if not then before calling runNow service, scheduling the job as draft to configure the scheduler and then making the runNow request
  • Loading branch information
ymaheshwari1 committed Apr 4, 2024
1 parent 7a6effe commit ae2ab9d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<h2>{{ translate("History") }}</h2>
<ion-button v-if="groupHistory.length" fill="clear" @click="showGroupHistory" slot="end">{{ translate("View All") }}</ion-button>
</ion-item>
<p class="empty-state" v-if="!groupHistory.length">{{ translate("No available history for this group") }}</p>
<p class="empty-state" v-if="!groupHistory.length || !groupHistory[0].startTime">{{ translate("No available history for this group") }}</p>
<ion-item v-else>
<ion-label>
<h3>{{ getTime(groupHistory[0].startTime) }}</h3>
Expand Down Expand Up @@ -352,6 +352,27 @@ async function runNow() {
{
text: translate("Run now"),
handler: async () => {
// Checking that if we already have the job schedule before calling runNow, because if the job scheduler is not present then runNow action can't be performed
// If the scheduler for the job is available then we will have jobName, if not then first scheduling the job in draft status just to create a routing schedule and then calling runNow action
if(!job.value.jobName) {
const payload = {
routingGroupId: props.routingGroupId,
paused: "Y",
}
try {
const resp = await OrderRoutingService.scheduleBrokering(payload)
if(hasError(resp)) {
throw resp.data
}
// Updating jobName as if the user again clicks the runNow button then in that we don't want to call the scheduleBrokering service
job.value.jobName = resp.data.jobName
} catch(err) {
logger.error(err)
return;
}
}
try {
const resp = await OrderRoutingService.runNow(props.routingGroupId)
if(!hasError(resp) && resp.data.jobRunId) {
Expand Down

0 comments on commit ae2ab9d

Please sign in to comment.