challenge-api icon indicating copy to clipboard operation
challenge-api copied to clipboard

Challenge phases not working properly

Open jmgasper opened this issue 5 years ago • 2 comments
trafficstars

There is one phase in timeline template doesn't exist in all challenge phases (https://api.topcoder-dev.com/v5/challenge-phases):

 {
        "phaseId": "6950164f-3c5e-4bdc-abc8-22aaf5a1bd49",
        "defaultDuration": 48
      },

the front end can't find the phase with id "6950164f-3c5e-4bdc-abc8-22aaf5a1bd49" in challenge phase so it will ignore this phase.

This phase doesn't come down from this endpoint: https://api.topcoder-dev.com/v5/challenge-phases

This line seems to be the culprit, in PhaseService.js:

const list = await helper.scan('Phase')

The scan will only return the first 20 phases, but we need to pull all of them.

jmgasper avatar May 06 '20 03:05 jmgasper

I'm not sure where this issue is specifically caused, but it looks like the update function calls populatePhases which uses: https://github.com/topcoder-platform/challenge-api/blob/develop/src/services/ChallengeService.js#L331

But these .scan( calls are going to bite us. Make sure if you have IDs you're looking up, you should be using the getById on each ID and querying the db rather than scanning. It's more efficient to loop through IDs and query for each one, than scan, especially because of the pagination.

rootelement avatar May 06 '20 04:05 rootelement

For now, I have updated the code to return the first 100 instead of 20 by default. This fixed the issue temporarily but we should indeed get rid of .scan()

ThomasKranitsas avatar May 06 '20 14:05 ThomasKranitsas