Skip to content

Commit

Permalink
Improved: added pagination on fetching data manager logs on the adjus…
Browse files Browse the repository at this point in the history
…t inventory history page(#304)
  • Loading branch information
R-Sourabh committed Jan 10, 2025
1 parent 67e3cbd commit 822452e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 17 additions & 9 deletions src/views/AdjustInventoryHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,27 @@ export default defineComponent ({
},
"fieldList": ["statusId", "logId", "createdDate", "startDateTime", "finishDateTime", "logFileContentId", "errorRecordContentId", "contentName", "dataResourceId"],
"noConditionFind": "Y",
"viewSize": 250,
"viewSize": 200,
"entityName": "DataManagerLogAndContent",
}
let fetchedLogs = [], viewIndex = 0, resp;
try {
const resp = await UtilService.fetchDataManagerLogs(payload);
if(resp.data.docs?.length > 0 && !hasError(resp)) {
this.dataManagerLogList = resp.data.docs;
this.filteredDataManagerLogList = [...this.dataManagerLogList];
} else {
throw resp.data;
}
} catch(err) {
do {
const currentPayload = { ...payload, viewIndex };
resp = await UtilService.fetchDataManagerLogs(currentPayload);
if(!hasError(resp) && resp.data.docs?.length > 0) {
fetchedLogs = fetchedLogs.concat(resp.data.docs)
viewIndex++
} else {
throw resp.data
}
} while(resp.data.docs?.length >= 200)
// After fetching all logs, update the state
this.dataManagerLogList = fetchedLogs;
this.filteredDataManagerLogList = [...this.dataManagerLogList];
} catch (err) {
logger.error(err);
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/views/ScheduledIncomingInventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ export default defineComponent({
},
async ionViewDidEnter() {
await this.store.dispatch('stock/fetchJobs')
this.updateJobsByStatus();
this.filterJobsByStatus();
},
methods: {
updateJobsByStatus() {
filterJobsByStatus() {
this.pendingJobs = this.jobs.filter(job => job.statusId === "SERVICE_PENDING");
this.finishedJobs = this.jobs.filter(job => job.statusId === "SERVICE_FINISHED");
},
Expand Down Expand Up @@ -201,7 +201,7 @@ export default defineComponent({
if(!hasError(resp) && resp.data.successMessage) {
await this.store.dispatch('stock/fetchJobs')
showToast(translate('Service updated successfully'))
this.updateJobsByStatus();
this.filterJobsByStatus();
} else {
throw resp.data
}
Expand Down

0 comments on commit 822452e

Please sign in to comment.