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

Commit de3ae77

Browse files
author
James Cori
committed
Merge branch 'develop'
2 parents 83f1e4d + d177f02 commit de3ae77

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/controllers/apiController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ async function retryFailed (req, res) {
8989
*/
9090
async function queueSync (req, res) {
9191
const force = _.toString(_.get(req, 'query.force')) === 'true'
92+
logger.debug(`Force Sync: ${force} - Legacy ID: ${req.query.legacyId}`)
9293
if (req.query.legacyId) {
9394
// Target a single challenge based on the provided legacyId if provided
9495
await syncController.queueChallenges({ legacyId: req.query.legacyId, force })

src/controllers/syncController.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const config = require('config')
22
const logger = require('../util/logger')
3+
const _ = require('lodash')
34
// const moment = require('moment')
45
const { slice, union, toString, toNumber, remove } = require('lodash')
56
const challengeSyncStatusService = require('../services/challengeSyncStatusService')
@@ -74,22 +75,28 @@ async function queueChallenges (filter) {
7475
let running = true
7576
let queuedCount = 0
7677

78+
// logger.debug(`Filter: ${JSON.stringify(filter)}`)
7779
// get active challenges from v4
78-
const { ids: v4IdArray } = await syncService.getV4ChallengeIds(filter)
80+
const v4response = await syncService.getV4ChallengeIds(filter)
81+
// logger.debug(`v4 Response: ${JSON.stringify(v4response)}`)
82+
const v4IdArray = _.map(_.get(v4response, 'ids', []), id => _.toNumber(id))
7983
// console.log('v4', v4IdArray)
80-
// logger.debug(`v4 Array ${v4IdArray}`)
84+
// logger.debug(`v4 Array ${JSON.stringify(v4IdArray)}`)
8185
// get active challenges from v5
82-
const { ids: v5IdArray } = await syncService.getV5LegacyChallengeIds(filter)
83-
// logger.debug(`v5 Array ${v5IdArray}`)
86+
const v5response = await syncService.getV5LegacyChallengeIds(filter)
87+
// logger.debug(`v5 Response: ${JSON.stringify(v5response)}`)
88+
const v5IdArray = _.map(_.get(v5response, 'ids', []), id => _.toNumber(id))
89+
// logger.debug(`v5 Array ${JSON.stringify(v5IdArray)}`)
8490

8591
// combine arrays, return unique
8692
const combinedArray = union(v4IdArray, v5IdArray)
8793
remove(combinedArray, n => toString(n) === 'NaN')
94+
remove(combinedArray, n => toString(n) === 'null')
8895
const totalChallengesCount = combinedArray.length
8996
// console.log('union length', combinedArray.length)
9097

91-
// logger.debug(`Sync :: Total to Sync ${totalChallengesCount}`)
92-
// logger.debug(`Combined Array ${combinedArray}`)
98+
logger.debug(`Sync :: Total to Sync ${totalChallengesCount}`)
99+
logger.debug(`Combined Array ${JSON.stringify(combinedArray)}`)
93100

94101
while (running) {
95102
if ((page * perPage) > combinedArray.length) {
@@ -120,10 +127,13 @@ async function queueChallengeById (legacyId, withLogging = false, force = false)
120127
logger.info(`Sync :: Queue challenge with ID: ${legacyId}`)
121128
}
122129

130+
// logger.debug(`queueChallengeById - Force Value: ${force} - Force Check: ${force === true}`)
123131
if (force === true) {
124132
// forced, do it anyway
125133
logger.info(`Sync :: Sync of ${legacyId} is being forced`)
126134
return challengeSyncStatusService.queueForSync(legacyId, true)
135+
// } else {
136+
// logger.debug(`Sync :: Sync Not Forced ${legacyId}`)
127137
}
128138

129139
// make sure it's not already queued

src/services/syncService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async function processChallenge (legacyId, challengeListing, challengeDetails) {
125125
// logger.debug(`intersection: ${JSON.stringify(prizeSets)}`)
126126

127127
const copilotPayment = await challengeIfxService.getCopilotPaymentFromIfx(legacyId)
128-
if (copilotPayment) {
128+
if (copilotPayment && _.toNumber(copilotPayment.amount) > 0) {
129129
prizeSets.push({
130130
prizes: [
131131
{

0 commit comments

Comments
 (0)