-
Notifications
You must be signed in to change notification settings - Fork 33
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
Implement bulk scheduling (#32j3gu0) #314
Conversation
…e UI for the same (#32j3gu0)
…sed handling (#32j3gu0)
…equency and time (#32j3gu0)
…d updating/replacing all the jobs (#32j3gu0)
…dated en.json (#32j3gu0)
… added locales in en.json and added message in UI for no jobs found (#32j3gu0)
… added locales in en.json and added message in UI for no jobs found (#32j3gu0)
src/store/modules/job/actions.ts
Outdated
job.runtimeData && Object.keys(job.runtimeData).map((key: any) => { | ||
if (job.runtimeData[key] === 'null') job.runtimeData[key] = '' | ||
}) | ||
jobParams.push({ ...job.runtimeData, ...params, jobId: job.jobId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not pass the jobId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated sir, now passing systemJobEnumId, as discussed.
src/store/modules/job/actions.ts
Outdated
|
||
if(freqType) { | ||
payload.freqType = freqType; | ||
if(freqType === 'slow') showToast(translate("This job has slow frequency type, hence, feasible frequency will be set automatically")) | ||
} | ||
// TODO: find a better solution instead of hardcoding 'EVERYDAY' | ||
payload.setTime = state.bulk.setTime; | ||
payload.frequency = (state.bulk.frequency && freqType === 'slow') ? 'EVERYDAY' : state.bulk.frequency; | ||
commit(types.JOB_ADDED_TO_BULK, payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(freqType) { | |
payload.freqType = freqType; | |
if(freqType === 'slow') showToast(translate("This job has slow frequency type, hence, feasible frequency will be set automatically")) | |
} | |
// TODO: find a better solution instead of hardcoding 'EVERYDAY' | |
payload.setTime = state.bulk.setTime; | |
payload.frequency = (state.bulk.frequency && freqType === 'slow') ? 'EVERYDAY' : state.bulk.frequency; | |
commit(types.JOB_ADDED_TO_BULK, payload); | |
payload.frequency = state.bulk.frequency; | |
if(freqType) { | |
payload.freqType = freqType; | |
if(freqType === 'slow') { | |
// TODO: find a better solution instead of hardcoding 'EVERYDAY' | |
payload.frequency = 'EVERYDAY' ; | |
showToast(translate("This job has slow frequency type, hence, feasible frequency will be set automatically")) | |
} | |
} | |
// TODO: find a better solution instead of hardcoding 'EVERYDAY' | |
payload.setTime = state.bulk.setTime; | |
commit(types.JOB_ADDED_TO_BULK, payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir, the code I wrote takes into account that if the frequency is set globally, then only we override it for jobs with slow freqType (payload.frequency = (state.bulk.frequency && freqType === 'slow') ? 'EVERYDAY' : state.bulk.frequency;
).
The suggested changes do not provide this functionality.
src/store/modules/job/actions.ts
Outdated
} | ||
// TODO: find a better solution instead of hardcoding 'EVERYDAY' | ||
payload.setTime = state.bulk.setTime; | ||
payload.frequency = (state.bulk.frequency && freqType === 'slow') ? 'EVERYDAY' : state.bulk.frequency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could implement a method that returns the feasible frequency based upon freqType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done sir
src/store/modules/job/actions.ts
Outdated
// As of now, the job will get scheduled again even if it is pending | ||
const jobParams = [] as any; | ||
let failedJobs = 0; | ||
payload.shopifyConfigs.map((shopId: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use reduce or could handle the returned object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/store/modules/job/actions.ts
Outdated
return Promise.reject(resp); | ||
} | ||
})).then((resps: any) => { | ||
resps.some((resp: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might fail if the request other than first one fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sir, updated the code to handle the case when jobs other than the first one fail.
src/store/modules/job/actions.ts
Outdated
setBulkJobData({ commit, state }, payload) { | ||
let bulkJobs = JSON.parse(JSON.stringify(state.bulk.jobs)); | ||
const value = payload.value, type = payload.type; | ||
if (payload.global) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have separate actions for bulk and configuration component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done sir
…r than the first job fails (#32j3gu0)
…map method to create params to send in scheduleJob service which can be improved by using array reduce method, as arrayMap always returns an array whereas reduce can be used to return single element which can be obejct or anything(#32j3gu0)
src/store/modules/job/actions.ts
Outdated
const jobParams = [] as any; | ||
let failedJobs = 0; | ||
payload.shopifyConfigs.map((shopId: string) => { | ||
return payload.jobs.reduce((params: any, job: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using reduce correct way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated sir
src/store/modules/job/actions.ts
Outdated
}, {}) | ||
}) | ||
|
||
Promise.allSettled(jobParams.map(async (param: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use async await
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir, the use of Promise.all will reject the next calls if a previous one fails.
src/store/modules/job/actions.ts
Outdated
const resp: any = await JobService.scheduleJob(param); | ||
if(resp.status === 200 && !hasError(resp)){ | ||
// Removing the scheduled job | ||
dispatch('removeBulkJob', param.systemJobEnumId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove them in bulk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated sir
src/store/modules/job/actions.ts
Outdated
// set the maximum slow frequency for slow type jobs if global frequnecy is set | ||
payload.frequency = (state.bulk.frequency && freqType === 'slow') ? (generateFrequencyOptions('slow') as any).pop().value : state.bulk.frequency; | ||
|
||
const bulk = JSON.parse(JSON.stringify(state.bulk.jobs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const bulk = JSON.parse(JSON.stringify(state.bulk.jobs)); | |
const bulkJobs = JSON.parse(JSON.stringify(state.bulk.jobs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/store/modules/job/actions.ts
Outdated
if(job.freqType === 'slow') { | ||
showToast(translate("Some jobs have slow frequency type, hence, feasible frequency will be set automatically")) | ||
// If user sets a valid slow frequency, we honour it else maximum frequency is set | ||
const slowFreqs = generateFrequencyOptions('slow').map((obj: any) => obj.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could generate them once and use further
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated sir
…ency and improved code (#32j3gu0)
…ulkScheduler (#32j3gu0)
Related Issues
Closes #304
Short Description and Why It's Useful
The bulk job scheduler enables scheduling multiple jobs at once. The user can select for which store and for which configs they want to schedule the jobs. It aids in the process of setting up the instance as one can ease the process by scheduling multiple jobs at once instead of manually scheduling like before.
Screenshots of Visual Changes before/after (If There Are Any)
IMPORTANT NOTICE - Remember to add changelog entry
Contribution and Currently Important Rules Acceptance