@@ -13,22 +13,24 @@ const ResourceBookingService = require('./ResourceBookingService')
13
13
14
14
/**
15
15
* Function to get assigned resource bookings with specific projectIds
16
+ * @param {Object } currentUser the user who perform this operation.
16
17
* @param {Array } projectIds project ids
17
18
* @returns the request result
18
19
*/
19
- async function _getAssignedResourceBookingsByProjectIds ( projectIds ) {
20
+ async function _getAssignedResourceBookingsByProjectIds ( currentUser , projectIds ) {
20
21
const criteria = { status : 'assigned' , projectIds }
21
- const { result } = await ResourceBookingService . searchResourceBookings ( criteria , { returnAll : true } )
22
+ const { result } = await ResourceBookingService . searchResourceBookings ( currentUser , criteria , { returnAll : true } )
22
23
return result
23
24
}
24
25
25
26
/**
26
27
* Function to get jobs by projectIds
28
+ * @param {Object } currentUser the user who perform this operation.
27
29
* @param {Array } projectIds project ids
28
30
* @returns the request result
29
31
*/
30
- async function _getJobsByProjectIds ( projectIds ) {
31
- const { result } = await JobService . searchJobs ( { projectIds } , { returnAll : true } )
32
+ async function _getJobsByProjectIds ( currentUser , projectIds ) {
33
+ const { result } = await JobService . searchJobs ( currentUser , { projectIds } , { returnAll : true } )
32
34
return result
33
35
}
34
36
@@ -54,7 +56,7 @@ async function searchTeams (currentUser, criteria) {
54
56
total,
55
57
page,
56
58
perPage,
57
- result : await getTeamDetail ( projects )
59
+ result : await getTeamDetail ( currentUser , projects )
58
60
}
59
61
}
60
62
@@ -75,16 +77,17 @@ searchTeams.schema = Joi.object().keys({
75
77
76
78
/**
77
79
* Get team details
80
+ * @param {Object } currentUser the user who perform this operation
78
81
* @param {Object } projects the projects
79
82
* @param {Object } isSearch the flag whether for search function
80
83
* @returns {Object } the search result
81
84
*/
82
- async function getTeamDetail ( projects , isSearch = true ) {
85
+ async function getTeamDetail ( currentUser , projects , isSearch = true ) {
83
86
const projectIds = _ . map ( projects , 'id' )
84
87
// Get all assigned resourceBookings filtered by projectIds
85
- const resourceBookings = await _getAssignedResourceBookingsByProjectIds ( projectIds )
88
+ const resourceBookings = await _getAssignedResourceBookingsByProjectIds ( currentUser , projectIds )
86
89
// Get all jobs filtered by projectIds
87
- const jobs = await _getJobsByProjectIds ( projectIds )
90
+ const jobs = await _getJobsByProjectIds ( currentUser , projectIds )
88
91
89
92
// Get first week day and last week day
90
93
const curr = new Date ( )
@@ -197,7 +200,7 @@ async function getTeamDetail (projects, isSearch = true) {
197
200
*/
198
201
async function getTeam ( currentUser , id ) {
199
202
const project = await helper . getProjectById ( currentUser , id )
200
- const result = await getTeamDetail ( [ project ] , false )
203
+ const result = await getTeamDetail ( currentUser , [ project ] , false )
201
204
const teamDetail = result [ 0 ]
202
205
203
206
// add job skills for result
@@ -246,7 +249,7 @@ getTeam.schema = Joi.object().keys({
246
249
*/
247
250
async function getTeamJob ( currentUser , id , jobId ) {
248
251
const project = await helper . getProjectById ( currentUser , id )
249
- const jobs = await _getJobsByProjectIds ( [ project . id ] )
252
+ const jobs = await _getJobsByProjectIds ( currentUser , [ project . id ] )
250
253
const job = _ . find ( jobs , { id : jobId } )
251
254
252
255
if ( ! job ) {
0 commit comments