@@ -295,7 +295,7 @@ function isDocumentMissingException (err) {
295
295
* @returns the request result
296
296
*/
297
297
async function getProjects ( token ) {
298
- const url = `${ config . TC_API } /projects?type=talent-as-a-service`
298
+ /* const url = `${config.TC_API}/projects?type=talent-as-a-service`
299
299
const res = await request
300
300
.get(url)
301
301
.query({
@@ -307,6 +307,30 @@ async function getProjects (token) {
307
307
localLogger.debug({ context: 'getProjects', message: `response body: ${JSON.stringify(res.body)}` })
308
308
return _.map(res.body, item => {
309
309
return _.pick(item, ['id', 'name'])
310
+ })*/
311
+
312
+ const url = `${ config . TC_API } /projects?type=talent-as-a-service`
313
+ let data = [ ]
314
+ let page = 1
315
+ while ( true ) {
316
+ const res = await request
317
+ . get ( url )
318
+ . query ( {
319
+ page,
320
+ memberOnly : true
321
+ } )
322
+ . set ( 'Authorization' , token )
323
+ . set ( 'Content-Type' , 'application/json' )
324
+ . set ( 'Accept' , 'application/json' )
325
+ localLogger . debug ( { context : 'getProjects' , message : `page ${ page } - response body: ${ JSON . stringify ( res . body ) } ` } )
326
+ data = [ ...data , ...res . body ]
327
+ page += 1
328
+ if ( ! res . headers [ 'x-next-page' ] ) {
329
+ break
330
+ }
331
+ }
332
+ return _ . map ( data , item => {
333
+ return _ . pick ( item , [ 'id' , 'name' ] )
310
334
} )
311
335
}
312
336
@@ -333,7 +357,7 @@ async function getUserById (token, userId) {
333
357
* @returns the request result
334
358
*/
335
359
async function getMembers ( token , handles ) {
336
- const handlesStr = _ . map ( handles , handle => {
360
+ /* const handlesStr = _.map(handles, handle => {
337
361
return '%22' + handle.toLowerCase() + '%22'
338
362
}).join(',')
339
363
const url = `${config.TC_API}/members?fields=userId,handleLower,photoURL&handlesLower=[${handlesStr}]`
@@ -344,7 +368,32 @@ async function getMembers (token, handles) {
344
368
.set('Content-Type', 'application/json')
345
369
.set('Accept', 'application/json')
346
370
localLogger.debug({ context: 'getMembers', message: `response body: ${JSON.stringify(res.body)}` })
347
- return res . body
371
+ return res.body */
372
+
373
+ const handlesStr = _ . map ( handles , handle => {
374
+ return '%22' + handle . toLowerCase ( ) + '%22'
375
+ } ) . join ( ',' )
376
+ const url = `${ config . TC_API } /members?fields=userId,handleLower,photoURL&handlesLower=[${ handlesStr } ]`
377
+
378
+ let data = [ ]
379
+ let page = 1
380
+ while ( true ) {
381
+ const res = await request
382
+ . get ( url )
383
+ . query ( {
384
+ page
385
+ } )
386
+ . set ( 'Authorization' , token )
387
+ . set ( 'Content-Type' , 'application/json' )
388
+ . set ( 'Accept' , 'application/json' )
389
+ localLogger . debug ( { context : 'getMembers' , message : `page ${ page } - response body: ${ JSON . stringify ( res . body ) } ` } )
390
+ data = [ ...data , ...res . body ]
391
+ page += 1
392
+ if ( ! res . headers [ 'x-next-page' ] ) {
393
+ break
394
+ }
395
+ }
396
+ return data
348
397
}
349
398
350
399
/**
0 commit comments