Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d2de697

Browse files
fix: archived jobs
1 parent 0aa35c8 commit d2de697

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/api/common/helper.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,11 @@ async function handlePlacedJobCandidates(jobCandidates, userId) {
334334
// Handle placed job status with RB result
335335
const rbRes = res.body;
336336
_.each(rbRes, (rb) => {
337-
const jc = jobCandidates.find(
338-
(item) => item.userId == rb.userId && item.jobId == rb.jobId
339-
);
340-
if (jc) {
341-
// jc.completed = (new Date(rb.endDate) <= new Date()) && rb.status == 'placed'
342-
jc.completed = rb.endDate ? new Date(rb.endDate) <= new Date() : false;
343-
}
337+
_.each(jobCandidates, (jc) => {
338+
if (rb.userId == jc.userId && rb.jobId == jc.userId) {
339+
jc.completed = rb.endDate ? new Date(rb.endDate) <= new Date() : false;
340+
}
341+
});
344342
});
345343
return;
346344
}

src/api/services/JobApplicationService.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ async function getMyJobApplications(currentUser, criteria) {
5555
// handle placed status for completed_jobs, archived_jobs query
5656
if (status && status != "open_jobs") {
5757
await helper.handlePlacedJobCandidates(jobCandidates.result, userId);
58-
jcResult = jobCandidates.result.filter(
59-
(item) =>
60-
item.status != "placed" || (item.status == "placed" && item.completed)
61-
);
58+
if (status == "completed_jobs") {
59+
jcResult = jobCandidates.result.filter(
60+
(item) => item.status == "placed" && item.completed
61+
);
62+
}
6263
}
6364

6465
const jobIds = _.map(jcResult, "jobId");
6566
// get jobs of current user by calling taas-api
6667
const { result: jobs } = await helper.getJobs({ jobIds, page: 1, perPage });
6768

6869
if (status && status == "archived_jobs") {
70+
jcResult = jobCandidates.result.filter(
71+
(item) =>
72+
item.status != "placed" || (item.status == "placed" && !item.completed)
73+
);
6974
helper.handleArchivedJobCandidates(jcResult, jobs);
7075
jcResult = jcResult.filter((item) => item.withdraw);
7176
}

0 commit comments

Comments
 (0)