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

Commit 3647058

Browse files
authored
Merge pull request #128 from topcoder-platform/revert-97-develop
Revert "prod release"
2 parents ed6a7e1 + 515acf3 commit 3647058

File tree

5 files changed

+51
-317
lines changed

5 files changed

+51
-317
lines changed

.circleci/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
version: 2
22
defaults: &defaults
33
docker:
4-
- image: cimg/python:3.11.0-browsers
4+
- image: circleci/python:2.7-stretch-browsers
55
install_dependency: &install_dependency
66
name: Installation of build and deployment dependencies.
77
command: |
8-
sudo apt update
98
sudo apt install jq
10-
sudo apt install python3-pip
119
sudo pip install awscli --upgrade
1210
sudo pip install docker-compose
1311
install_deploysuite: &install_deploysuite

src/constants.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ const challengeStatuses = {
4848
CancelledPaymentFailed: 'Cancelled - Payment Failed'
4949
}
5050

51-
const scorecardQuestionMapping = {
52-
30002212: [
53-
{
54-
questionId: 30007531,
55-
description: 'Does the submission sufficiently satisfy the requirements as described in the provided specification?'
56-
},
57-
{
58-
questionId: 30007533,
59-
description: 'How would you rate the work ethic of this submitter?'
60-
},
61-
{
62-
questionId: 30007532,
63-
description: 'How would you rate the quality of this submitters work?'
64-
}
65-
]
66-
}
67-
6851
const PhaseStatusTypes = {
6952
Scheduled: 1,
7053
Open: 2,
@@ -172,6 +155,5 @@ module.exports = {
172155
challengeStatuses,
173156
PhaseStatusTypes,
174157
prizeTypesIds,
175-
supportedMetadata,
176-
scorecardQuestionMapping
158+
supportedMetadata
177159
}

src/services/ProcessorService.js

Lines changed: 36 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const paymentService = require('./paymentService')
1919
const { createOrSetNumberOfReviewers } = require('./selfServiceReviewerService')
2020
const { disableTimelineNotifications } = require('./selfServiceNotificationService')
2121
const legacyChallengeService = require('./legacyChallengeService')
22-
const legacyChallengeReviewService = require('./legacyChallengeReviewService')
2322

2423
/**
2524
* Drop and recreate phases in ifx
@@ -52,30 +51,6 @@ async function recreatePhases (legacyId, v5Phases, createdBy) {
5251
phase.duration * 1000,
5352
createdBy
5453
)
55-
//Handle checkpoint phases
56-
//Magic numbers: 15=checkpoint submission, 16=checkpoint screen, 17=checkpoint review, 1=registration
57-
//For dependencyStart: 1=start, 0=end
58-
if(phaseLegacyId==17){
59-
logger.info(`Creating phase dependencies for checkpoint phases`)
60-
61-
const registrationPhaseId = await timelineService.getProjectPhaseId(legacyId, 1)
62-
const checkpointSubmissionPhaseId = await timelineService.getProjectPhaseId(legacyId, 15)
63-
const checkpointScreeningPhaseId = await timelineService.getProjectPhaseId(legacyId, 16)
64-
const checkpointReviewPhaseId = await timelineService.getProjectPhaseId(legacyId, 17)
65-
66-
await timelineService.insertPhaseDependency(registrationPhaseId, checkpointSubmissionPhaseId, 1, createdBy)
67-
await timelineService.insertPhaseDependency(checkpointSubmissionPhaseId, checkpointScreeningPhaseId, 0, createdBy)
68-
await timelineService.insertPhaseDependency(checkpointScreeningPhaseId, checkpointReviewPhaseId, 0, createdBy)
69-
70-
logger.info(`Creating default scorecard records for checkpoint phases`)
71-
//30001364 is the default checkpoint screening scorecard for studio (https://software.topcoder-dev.com/review/actions/ViewScorecard?scid=30001364)
72-
await timelineService.insertScorecardId(checkpointScreeningPhaseId, 30001364, createdBy)
73-
74-
//30001364 is the default checkpoint review scorecard for studio (https://software.topcoder-dev.com/review/actions/ViewScorecard?scid=30001004)
75-
await timelineService.insertScorecardId(checkpointReviewPhaseId, 30001004, createdBy)
76-
77-
78-
}
7954
} else if (!phaseLegacyId) {
8055
logger.warn(`Could not create phase ${phase.name} on legacy!`)
8156
}
@@ -104,53 +79,42 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService
10479
const phasesFromIFx = await timelineService.getChallengePhases(legacyId)
10580
logger.debug(`Phases from v5: ${JSON.stringify(v5Phases)}`)
10681
logger.debug(`Phases from IFX: ${JSON.stringify(phasesFromIFx)}`)
107-
let phaseGroups = {}
108-
_.forEach(phasesFromIFx, p => {
109-
if (!phaseGroups[p.phase_type_id]) {
110-
phaseGroups[p.phase_type_id] = []
82+
for (const phase of phasesFromIFx) {
83+
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
84+
const v5Equivalent = _.find(v5Phases, p => p.name === phaseName)
85+
logger.info(`v4 Phase: ${JSON.stringify(phase)}, v5 Equiv: ${JSON.stringify(v5Equivalent)}`)
86+
if (v5Equivalent) {
87+
// Compare duration and status
88+
// if (v5Equivalent.duration * 1000 !== phase.duration * 1 || isSelfService) {
89+
// ||
90+
// (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) ||
91+
// (!v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Open)) {
92+
// const newStatus = v5Equivalent.isOpen
93+
// ? constants.PhaseStatusTypes.Open
94+
// : (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
95+
// update phase
96+
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
97+
const newStatus = v5Equivalent.isOpen
98+
? constants.PhaseStatusTypes.Open
99+
: (_.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Scheduled ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
100+
await timelineService.updatePhase(
101+
phase.project_phase_id,
102+
legacyId,
103+
v5Equivalent.scheduledStartDate,
104+
v5Equivalent.scheduledEndDate,
105+
v5Equivalent.duration * 1000,
106+
newStatus // phase.phase_status_id
107+
)
108+
// newStatus)
109+
// } else {
110+
// logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
111+
// }
112+
} else {
113+
logger.info(`No v5 Equivalent Found for ${phaseName}`)
111114
}
112-
phaseGroups[p.phase_type_id].push(p)
113-
})
114-
_.forEach(_.cloneDeep(phaseGroups), (pg, pt) => {
115-
phaseGroups[pt] = _.sortBy(pg, 'scheduled_start_time')
116-
})
117-
118-
for (const key of _.keys(phaseGroups)) {
119-
let phaseOrder = 0
120-
let v5Equivalents = undefined
121-
for (const phase of phaseGroups[key]) {
122-
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
123-
if (_.isUndefined(v5Equivalents)) {
124-
v5Equivalents = _.sortBy(_.filter(v5Phases, p => p.name === phaseName), 'scheduledStartDate')
125-
}
126-
if (v5Equivalents.length > 0) {
127-
if (v5Equivalents.length === phaseGroups[key].length) {
128-
const v5Equivalent = v5Equivalents[phaseOrder]
129-
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
130-
let newStatus = _.toInteger(phase.phase_status_id)
131-
if (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) {
132-
newStatus = constants.PhaseStatusTypes.Scheduled
133-
}
134-
await timelineService.updatePhase(
135-
phase.project_phase_id,
136-
legacyId,
137-
phase.fixed_start_time ? v5Equivalent.scheduledStartDate : null,
138-
v5Equivalent.scheduledStartDate,
139-
v5Equivalent.scheduledEndDate,
140-
v5Equivalent.duration * 1000,
141-
newStatus
142-
)
143-
} else {
144-
logger.info(`number of ${phaseName} does not match`)
145-
}
146-
} else {
147-
logger.info(`No v5 Equivalent Found for ${phaseName}`)
148-
}
149-
if (isSelfService && phaseName === 'Review') {
150-
// make sure to set the required reviewers to 2
151-
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
152-
}
153-
phaseOrder = phaseOrder + 1
115+
if (isSelfService && phaseName === 'Review') {
116+
// make sure to set the required reviewers to 2
117+
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
154118
}
155119
}
156120
// TODO: What about iterative reviews? There can be many for the same challenge.
@@ -737,28 +701,6 @@ async function processMessage (message) {
737701
throw new Error(`Error getting challenge by id - Error: ${JSON.stringify(e)}`)
738702
}
739703

740-
// If iterative review is open
741-
if (_.find(_.get(message.payload, 'phases'), p => p.isOpen && p.name === 'Iterative Review')) {
742-
// Try to read reviews and insert them into informix DB
743-
if (message.payload.metadata && message.payload.legacy.reviewScorecardId) {
744-
let orReviewFeedback = _.find(message.payload.metadata, meta => meta.name === 'or_review_feedback')
745-
let orReviewScore = _.find(message.payload.metadata, meta => meta.name === 'or_review_score')
746-
if (!_.isUndefined(orReviewFeedback) && !_.isUndefined(orReviewScore)) {
747-
orReviewFeedback = JSON.parse(orReviewFeedback)
748-
const reviewResponses = []
749-
_.each(orReviewFeedback, (value, key) => {
750-
const questionId = _.get(_.find(constants.scorecardQuestionMapping[message.payload.legacy.reviewScorecardId], item => _.toString(item.questionId) === _.toString(key) || _.toLower(item.description) === _.toLower(key)), 'questionId')
751-
reviewResponses.push({
752-
questionId,
753-
answer: value
754-
})
755-
})
756-
orReviewScore = _.toNumber(orReviewFeedback)
757-
await legacyChallengeReviewService.insertReview(legacyId, message.payload.legacy.reviewScorecardId, orReviewScore, reviewResponses, createdByUserId)
758-
}
759-
}
760-
}
761-
762704
if (message.payload.status && challenge) {
763705
// Whether we need to sync v4 ES again
764706
let needSyncV4ES = false
@@ -846,7 +788,7 @@ processMessage.schema = {
846788
prizeSets: Joi.array().items(Joi.object().keys({
847789
type: Joi.string().valid(_.values(constants.prizeSetTypes)).required(),
848790
prizes: Joi.array().items(Joi.object().keys({
849-
value: Joi.number().min(0).required()
791+
value: Joi.number().positive().required()
850792
}).unknown(true))
851793
}).unknown(true)).min(1),
852794
tags: Joi.array().items(Joi.string().required()).min(1), // tag names

src/services/legacyChallengeReviewService.js

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)