Skip to content

Commit e192960

Browse files
committed
populate jobIds in resources for GET /taas-teams/:id and populate skills for GET /taas-teams/:id/jobs/:jobId
1 parent 6763c7d commit e192960

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/services/TeamService.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,19 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
111111
}
112112

113113
const usersPromises = []
114-
_.map(rbs, (rb) => { usersPromises.push(helper.getUserById(currentUser.jwtToken, rb.userId)) })
114+
_.map(rbs, (rb) => {
115+
usersPromises.push(
116+
helper.getUserById(currentUser.jwtToken, rb.userId)
117+
.then(user => {
118+
// If call function is not search, add jobId field
119+
if (!isSearch) {
120+
user.jobId = rb.jobId
121+
user.customerRate = rb.customerRate
122+
}
123+
return user
124+
})
125+
)
126+
})
115127
const userInfos = await Promise.all(usersPromises)
116128
if (userInfos && userInfos.length > 0) {
117129
res.resources = userInfos
@@ -125,21 +137,6 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
125137
if (findMember && findMember.photoURL) {
126138
item.photo_url = findMember.photoURL
127139
}
128-
129-
if (!isSearch) {
130-
// If call function is not search, add job field
131-
const findRbs = _.find(rbs, { userId: item.id })
132-
if (findRbs) {
133-
item.customerRate = findRbs.customerRate
134-
const job = _.find(jobs, { id: findRbs.jobId })
135-
if (job) {
136-
item.job = {
137-
id: job.id,
138-
name: job.description
139-
}
140-
}
141-
}
142-
}
143140
}
144141
}
145142
}
@@ -236,7 +233,8 @@ async function getTeamJob (currentUser, id, jobId) {
236233
}
237234
const result = {
238235
id: job.id,
239-
description: job.description
236+
description: job.description,
237+
skills: job.skills
240238
}
241239

242240
const jobSkills = job.skills

0 commit comments

Comments
 (0)