@@ -295,7 +295,7 @@ function isDocumentMissingException (err) {
295295 * @returns the request result
296296 */
297297async 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`
299299 const res = await request
300300 .get(url)
301301 .query({
@@ -307,6 +307,30 @@ async function getProjects (token) {
307307 localLogger.debug({ context: 'getProjects', message: `response body: ${JSON.stringify(res.body)}` })
308308 return _.map(res.body, item => {
309309 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' ] )
310334 } )
311335}
312336
@@ -333,7 +357,7 @@ async function getUserById (token, userId) {
333357 * @returns the request result
334358 */
335359async function getMembers ( token , handles ) {
336- const handlesStr = _ . map ( handles , handle => {
360+ /* const handlesStr = _.map(handles, handle => {
337361 return '%22' + handle.toLowerCase() + '%22'
338362 }).join(',')
339363 const url = `${config.TC_API}/members?fields=userId,handleLower,photoURL&handlesLower=[${handlesStr}]`
@@ -344,7 +368,32 @@ async function getMembers (token, handles) {
344368 .set('Content-Type', 'application/json')
345369 .set('Accept', 'application/json')
346370 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
348397}
349398
350399/**
0 commit comments