Skip to content

Commit 54c4039

Browse files
authored
Merge pull request #38 from topcoder-platform/develop
adding log statements for debugging
2 parents b234462 + fc99b16 commit 54c4039

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/common/helper.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const elasticsearch = require('elasticsearch')
1212
const uuid = require('uuid/v4')
1313
const querystring = require('querystring')
1414
const request = require('request')
15+
const logger = require("./logger");
1516

1617
// Color schema for Ratings
1718
const RATING_COLORS = [{
@@ -43,7 +44,7 @@ const awsConfig = {
4344
}
4445
if (config.AMAZON.AWS_ACCESS_KEY_ID && config.AMAZON.AWS_SECRET_ACCESS_KEY) {
4546
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
4748
}
4849
AWS.config.update(awsConfig)
4950

@@ -668,9 +669,13 @@ async function parseGroupIds (groupIds) {
668669
newIdArray.push(id)
669670
} else {
670671
try {
671-
const { oldId } = await getGroupId(id)
672+
logger.info(`parseGroupIds: fetch old id from uuid ${id}`)
673+
const { oldId } = await getGroupId(id)
672674
if (oldId != null && oldId.trim() != '') {
673675
newIdArray.push(oldId)
676+
logger.info(`parseGroupIds: old id found ${oldId}`)
677+
} else {
678+
logger.info(`parseGroupIds: old id not found for uuid ${id}`)
674679
}
675680
} catch (err) { }
676681
}
@@ -681,14 +686,17 @@ async function parseGroupIds (groupIds) {
681686
async function getGroupId (id) {
682687
const token = await getM2MToken()
683688
return new Promise(function (resolve, reject) {
689+
logger.info(`calling groups API ${config.GROUPS_API_URL}/${id}`)
684690
request({ url: `${config.GROUPS_API_URL}/${id}`,
685691
headers: {
686692
Authorization: `Bearer ${token}`
687693
} },
688694
function (error, response, body) {
689695
if (response.statusCode === 200) {
696+
logger.info(`response from groups API ${response.body}`)
690697
resolve(JSON.parse(body))
691698
} else {
699+
logger.error(error)
692700
reject(error)
693701
}
694702
}

src/services/StatisticsService.js

+4
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,18 @@ async function getMemberStats (currentUser, handle, query, throwError) {
192192
let stat
193193
try {
194194
// get statistics private by member user id from Elasticsearch
195+
logger.info(`getMemberStats: fetching stats for group ${groupId}`)
195196
stat = await esClient.get({
196197
index: config.ES.MEMBER_STATS_ES_INDEX,
197198
type: config.ES.MEMBER_STATS_ES_TYPE,
198199
id: member.userId + '_' + groupId
199200
})
200201
if (stat.hasOwnProperty('_source')) {
201202
stat = stat._source
203+
logger.info(`getMemberStats: stats found for groupId ${groupId}`)
202204
}
203205
} catch (error) {
206+
logger.info(`getMemberStats: failed to get stats from es for groupId ${groupId}`)
204207
if (error.displayName === 'NotFound') {
205208
if (groupId === '10') {
206209
// get statistics by member user id from dynamodb
@@ -212,6 +215,7 @@ async function getMemberStats (currentUser, handle, query, throwError) {
212215
} else {
213216
// get statistics private by member user id from dynamodb
214217
stat = await helper.getEntityByHashRangeKey(handle, 'MemberStatsPrivate', 'userId', member.userId, 'groupId', groupId, false)
218+
logger.info(`getMemberStats: retrieved ${JSON.stringify(stat)} for groupId ${groupId}.`)
215219
}
216220
}
217221
}

0 commit comments

Comments
 (0)