Skip to content

Commit fc99b16

Browse files
authored
Merge pull request #36 from topcoder-platform/doc/debug-logs
Doc/debug logs
2 parents 61e28ea + 6507a7a commit fc99b16

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/common/helper.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const awsConfig = {
4444
}
4545
if (config.AMAZON.AWS_ACCESS_KEY_ID && config.AMAZON.AWS_SECRET_ACCESS_KEY) {
4646
awsConfig.accessKeyId = config.AMAZON.AWS_ACCESS_KEY_ID
47-
awsConfig.secretAccessKey = config.AMAZON.AWS_SECRET_ACCESS_KEY
47+
awsConfig.secretAccessKey = config.AMAZON.AWS_SECRET_ACCESS_KEY
4848
}
4949
AWS.config.update(awsConfig)
5050

@@ -669,9 +669,13 @@ async function parseGroupIds (groupIds) {
669669
newIdArray.push(id)
670670
} else {
671671
try {
672-
const { oldId } = await getGroupId(id)
672+
logger.info(`parseGroupIds: fetch old id from uuid ${id}`)
673+
const { oldId } = await getGroupId(id)
673674
if (oldId != null && oldId.trim() != '') {
674675
newIdArray.push(oldId)
676+
logger.info(`parseGroupIds: old id found ${oldId}`)
677+
} else {
678+
logger.info(`parseGroupIds: old id not found for uuid ${id}`)
675679
}
676680
} catch (err) { }
677681
}
@@ -682,13 +686,14 @@ async function parseGroupIds (groupIds) {
682686
async function getGroupId (id) {
683687
const token = await getM2MToken()
684688
return new Promise(function (resolve, reject) {
685-
logger.info(`calling grouops API ${config.GROUPS_API_URL}/${id}`)
689+
logger.info(`calling groups API ${config.GROUPS_API_URL}/${id}`)
686690
request({ url: `${config.GROUPS_API_URL}/${id}`,
687691
headers: {
688692
Authorization: `Bearer ${token}`
689693
} },
690694
function (error, response, body) {
691695
if (response.statusCode === 200) {
696+
logger.info(`response from groups API ${response.body}`)
692697
resolve(JSON.parse(body))
693698
} else {
694699
logger.error(error)

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)