@@ -12,6 +12,7 @@ const elasticsearch = require('elasticsearch')
12
12
const uuid = require ( 'uuid/v4' )
13
13
const querystring = require ( 'querystring' )
14
14
const request = require ( 'request' )
15
+ const logger = require ( "./logger" ) ;
15
16
16
17
// Color schema for Ratings
17
18
const RATING_COLORS = [ {
@@ -43,7 +44,7 @@ const awsConfig = {
43
44
}
44
45
if ( config . AMAZON . AWS_ACCESS_KEY_ID && config . AMAZON . AWS_SECRET_ACCESS_KEY ) {
45
46
awsConfig . accessKeyId = config . AMAZON . AWS_ACCESS_KEY_ID
46
- awsConfig . secretAccessKey = config . AMAZON . AWS_SECRET_ACCESS_KEY
47
+ awsConfig . secretAccessKey = config . AMAZON . AWS_SECRET_ACCESS_KEY
47
48
}
48
49
AWS . config . update ( awsConfig )
49
50
@@ -668,9 +669,13 @@ async function parseGroupIds (groupIds) {
668
669
newIdArray . push ( id )
669
670
} else {
670
671
try {
671
- const { oldId } = await getGroupId ( id )
672
+ logger . info ( `parseGroupIds: fetch old id from uuid ${ id } ` )
673
+ const { oldId } = await getGroupId ( id )
672
674
if ( oldId != null && oldId . trim ( ) != '' ) {
673
675
newIdArray . push ( oldId )
676
+ logger . info ( `parseGroupIds: old id found ${ oldId } ` )
677
+ } else {
678
+ logger . info ( `parseGroupIds: old id not found for uuid ${ id } ` )
674
679
}
675
680
} catch ( err ) { }
676
681
}
@@ -681,14 +686,17 @@ async function parseGroupIds (groupIds) {
681
686
async function getGroupId ( id ) {
682
687
const token = await getM2MToken ( )
683
688
return new Promise ( function ( resolve , reject ) {
689
+ logger . info ( `calling groups API ${ config . GROUPS_API_URL } /${ id } ` )
684
690
request ( { url : `${ config . GROUPS_API_URL } /${ id } ` ,
685
691
headers : {
686
692
Authorization : `Bearer ${ token } `
687
693
} } ,
688
694
function ( error , response , body ) {
689
695
if ( response . statusCode === 200 ) {
696
+ logger . info ( `response from groups API ${ response . body } ` )
690
697
resolve ( JSON . parse ( body ) )
691
698
} else {
699
+ logger . error ( error )
692
700
reject ( error )
693
701
}
694
702
}
0 commit comments