Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit c464bcc

Browse files
author
James Cori
committed
Adding Logging
1 parent 80f73e4 commit c464bcc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/services/ProcessorService.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const copilotPaymentService = require('./copilotPaymentService')
1616
const timelineService = require('./timelineService')
1717
const metadataService = require('./metadataService')
1818
const paymentService = require('./paymentService')
19-
const { parse } = require('superagent')
2019

2120
/**
2221
* Drop and recreate phases in ifx
@@ -74,10 +73,12 @@ async function recreatePhases (legacyId, v5Phases, createdBy) {
7473
async function syncChallengePhases (legacyId, v5Phases) {
7574
const phaseTypes = await timelineService.getPhaseTypes()
7675
const phasesFromIFx = await timelineService.getChallengePhases(legacyId)
76+
logger.debug(`Phases from v5: ${JSON.stringify(v5Phases)}`)
7777
logger.debug(`Phases from IFX: ${JSON.stringify(phasesFromIFx)}`)
7878
for (const phase of phasesFromIFx) {
7979
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
8080
const v5Equivalent = _.find(v5Phases, p => p.name === phaseName)
81+
logger.info(`Phase name: ${phaseName}, v5 Equiv: ${JSON.stringify(v5Equivalent)}`)
8182
if (v5Equivalent) {
8283
// Compare duration and status
8384
if (v5Equivalent.duration * 1000 !== phase.duration) {
@@ -98,7 +99,11 @@ async function syncChallengePhases (legacyId, v5Phases) {
9899
phase.phase_status_id
99100
)
100101
// newStatus)
102+
} else {
103+
logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
101104
}
105+
} else {
106+
logger.info(`No v5 Equivalent Found for ${phaseName}`)
102107
}
103108
}
104109
// TODO: What about iterative reviews? There can be many for the same challenge.
@@ -653,7 +658,7 @@ async function processMessage (message) {
653658
try {
654659
metaValue = constants.supportedMetadata[metadataKey].method(message.payload, constants.supportedMetadata[metadataKey].defaultValue)
655660
if (metaValue !== null && metaValue !== '') {
656-
logger.info(`Setting ${constants.supportedMetadata[metadataKey].description} to ${metaValue}`)
661+
// logger.info(`Setting ${constants.supportedMetadata[metadataKey].description} to ${metaValue}`)
657662
await metadataService.createOrUpdateMetadata(legacyId, metadataKey, metaValue, updatedByUserId)
658663
}
659664
} catch (e) {

src/services/metadataService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ async function createOrUpdateMetadata (challengeLegacyId, typeId, value, created
5858
const [existing] = await getMetadataEntry(challengeLegacyId, typeId)
5959
if (existing) {
6060
if (value) {
61-
logger.info(`Metadata ${typeId} exists. Will update`)
61+
// logger.info(`Metadata ${typeId} exists. Will update`)
6262
const query = await prepare(connection, QUERY_UPDATE)
6363
result = await query.executeAsync([value, createdBy, typeId, challengeLegacyId])
6464
} else {
65-
logger.info(`Metadata ${typeId} exists. Will delete`)
65+
// logger.info(`Metadata ${typeId} exists. Will delete`)
6666
const query = await prepare(connection, QUERY_DELETE)
6767
result = await query.executeAsync([challengeLegacyId, typeId])
6868
}
6969
} else {
70-
logger.info(`Metadata ${typeId} does not exist. Will create`)
70+
// logger.info(`Metadata ${typeId} does not exist. Will create`)
7171
const query = await prepare(connection, QUERY_CREATE)
7272
result = await query.executeAsync([challengeLegacyId, typeId, value, createdBy, createdBy])
7373
}
7474
// await connection.commitTransactionAsync()
75-
logger.info(`Metadata with typeId ${typeId} has been enabled for challenge ${challengeLegacyId}`)
75+
// logger.info(`Metadata with typeId ${typeId} has been enabled for challenge ${challengeLegacyId}`)
7676
} catch (e) {
7777
logger.error(`Error in 'createOrUpdateMetadata' ${e}, rolling back transaction`)
7878
await connection.rollbackTransactionAsync()

0 commit comments

Comments
 (0)