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

Revert "prod release" #128

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version: 2
defaults: &defaults
docker:
- image: cimg/python:3.11.0-browsers
- image: circleci/python:2.7-stretch-browsers
install_dependency: &install_dependency
name: Installation of build and deployment dependencies.
command: |
sudo apt update
sudo apt install jq
sudo apt install python3-pip
sudo pip install awscli --upgrade
sudo pip install docker-compose
install_deploysuite: &install_deploysuite
Expand Down
20 changes: 1 addition & 19 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ const challengeStatuses = {
CancelledPaymentFailed: 'Cancelled - Payment Failed'
}

const scorecardQuestionMapping = {
30002212: [
{
questionId: 30007531,
description: 'Does the submission sufficiently satisfy the requirements as described in the provided specification?'
},
{
questionId: 30007533,
description: 'How would you rate the work ethic of this submitter?'
},
{
questionId: 30007532,
description: 'How would you rate the quality of this submitters work?'
}
]
}

const PhaseStatusTypes = {
Scheduled: 1,
Open: 2,
Expand Down Expand Up @@ -172,6 +155,5 @@ module.exports = {
challengeStatuses,
PhaseStatusTypes,
prizeTypesIds,
supportedMetadata,
scorecardQuestionMapping
supportedMetadata
}
130 changes: 36 additions & 94 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const paymentService = require('./paymentService')
const { createOrSetNumberOfReviewers } = require('./selfServiceReviewerService')
const { disableTimelineNotifications } = require('./selfServiceNotificationService')
const legacyChallengeService = require('./legacyChallengeService')
const legacyChallengeReviewService = require('./legacyChallengeReviewService')

/**
* Drop and recreate phases in ifx
Expand Down Expand Up @@ -52,30 +51,6 @@ async function recreatePhases (legacyId, v5Phases, createdBy) {
phase.duration * 1000,
createdBy
)
//Handle checkpoint phases
//Magic numbers: 15=checkpoint submission, 16=checkpoint screen, 17=checkpoint review, 1=registration
//For dependencyStart: 1=start, 0=end
if(phaseLegacyId==17){
logger.info(`Creating phase dependencies for checkpoint phases`)

const registrationPhaseId = await timelineService.getProjectPhaseId(legacyId, 1)
const checkpointSubmissionPhaseId = await timelineService.getProjectPhaseId(legacyId, 15)
const checkpointScreeningPhaseId = await timelineService.getProjectPhaseId(legacyId, 16)
const checkpointReviewPhaseId = await timelineService.getProjectPhaseId(legacyId, 17)

await timelineService.insertPhaseDependency(registrationPhaseId, checkpointSubmissionPhaseId, 1, createdBy)
await timelineService.insertPhaseDependency(checkpointSubmissionPhaseId, checkpointScreeningPhaseId, 0, createdBy)
await timelineService.insertPhaseDependency(checkpointScreeningPhaseId, checkpointReviewPhaseId, 0, createdBy)

logger.info(`Creating default scorecard records for checkpoint phases`)
//30001364 is the default checkpoint screening scorecard for studio (https://software.topcoder-dev.com/review/actions/ViewScorecard?scid=30001364)
await timelineService.insertScorecardId(checkpointScreeningPhaseId, 30001364, createdBy)

//30001364 is the default checkpoint review scorecard for studio (https://software.topcoder-dev.com/review/actions/ViewScorecard?scid=30001004)
await timelineService.insertScorecardId(checkpointReviewPhaseId, 30001004, createdBy)


}
} else if (!phaseLegacyId) {
logger.warn(`Could not create phase ${phase.name} on legacy!`)
}
Expand Down Expand Up @@ -104,53 +79,42 @@ async function syncChallengePhases (legacyId, v5Phases, createdBy, isSelfService
const phasesFromIFx = await timelineService.getChallengePhases(legacyId)
logger.debug(`Phases from v5: ${JSON.stringify(v5Phases)}`)
logger.debug(`Phases from IFX: ${JSON.stringify(phasesFromIFx)}`)
let phaseGroups = {}
_.forEach(phasesFromIFx, p => {
if (!phaseGroups[p.phase_type_id]) {
phaseGroups[p.phase_type_id] = []
for (const phase of phasesFromIFx) {
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
const v5Equivalent = _.find(v5Phases, p => p.name === phaseName)
logger.info(`v4 Phase: ${JSON.stringify(phase)}, v5 Equiv: ${JSON.stringify(v5Equivalent)}`)
if (v5Equivalent) {
// Compare duration and status
// if (v5Equivalent.duration * 1000 !== phase.duration * 1 || isSelfService) {
// ||
// (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) ||
// (!v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Open)) {
// const newStatus = v5Equivalent.isOpen
// ? constants.PhaseStatusTypes.Open
// : (new Date().getTime() <= new Date(v5Equivalent.scheduledEndDate).getTime() ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
// update phase
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
const newStatus = v5Equivalent.isOpen
? constants.PhaseStatusTypes.Open
: (_.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Scheduled ? constants.PhaseStatusTypes.Scheduled : constants.PhaseStatusTypes.Closed)
await timelineService.updatePhase(
phase.project_phase_id,
legacyId,
v5Equivalent.scheduledStartDate,
v5Equivalent.scheduledEndDate,
v5Equivalent.duration * 1000,
newStatus // phase.phase_status_id
)
// newStatus)
// } else {
// logger.info(`Durations for ${phaseName} match: ${v5Equivalent.duration * 1000} === ${phase.duration}`)
// }
} else {
logger.info(`No v5 Equivalent Found for ${phaseName}`)
}
phaseGroups[p.phase_type_id].push(p)
})
_.forEach(_.cloneDeep(phaseGroups), (pg, pt) => {
phaseGroups[pt] = _.sortBy(pg, 'scheduled_start_time')
})

for (const key of _.keys(phaseGroups)) {
let phaseOrder = 0
let v5Equivalents = undefined
for (const phase of phaseGroups[key]) {
const phaseName = _.get(_.find(phaseTypes, pt => pt.phase_type_id === phase.phase_type_id), 'name')
if (_.isUndefined(v5Equivalents)) {
v5Equivalents = _.sortBy(_.filter(v5Phases, p => p.name === phaseName), 'scheduledStartDate')
}
if (v5Equivalents.length > 0) {
if (v5Equivalents.length === phaseGroups[key].length) {
const v5Equivalent = v5Equivalents[phaseOrder]
logger.debug(`Will update phase ${phaseName}/${v5Equivalent.name} from ${phase.duration} to duration ${v5Equivalent.duration * 1000} milli`)
let newStatus = _.toInteger(phase.phase_status_id)
if (v5Equivalent.isOpen && _.toInteger(phase.phase_status_id) === constants.PhaseStatusTypes.Closed) {
newStatus = constants.PhaseStatusTypes.Scheduled
}
await timelineService.updatePhase(
phase.project_phase_id,
legacyId,
phase.fixed_start_time ? v5Equivalent.scheduledStartDate : null,
v5Equivalent.scheduledStartDate,
v5Equivalent.scheduledEndDate,
v5Equivalent.duration * 1000,
newStatus
)
} else {
logger.info(`number of ${phaseName} does not match`)
}
} else {
logger.info(`No v5 Equivalent Found for ${phaseName}`)
}
if (isSelfService && phaseName === 'Review') {
// make sure to set the required reviewers to 2
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
}
phaseOrder = phaseOrder + 1
if (isSelfService && phaseName === 'Review') {
// make sure to set the required reviewers to 2
await createOrSetNumberOfReviewers(_.toString(phase.project_phase_id), _.toString(numOfReviewers), _.toString(createdBy))
}
}
// TODO: What about iterative reviews? There can be many for the same challenge.
Expand Down Expand Up @@ -737,28 +701,6 @@ async function processMessage (message) {
throw new Error(`Error getting challenge by id - Error: ${JSON.stringify(e)}`)
}

// If iterative review is open
if (_.find(_.get(message.payload, 'phases'), p => p.isOpen && p.name === 'Iterative Review')) {
// Try to read reviews and insert them into informix DB
if (message.payload.metadata && message.payload.legacy.reviewScorecardId) {
let orReviewFeedback = _.find(message.payload.metadata, meta => meta.name === 'or_review_feedback')
let orReviewScore = _.find(message.payload.metadata, meta => meta.name === 'or_review_score')
if (!_.isUndefined(orReviewFeedback) && !_.isUndefined(orReviewScore)) {
orReviewFeedback = JSON.parse(orReviewFeedback)
const reviewResponses = []
_.each(orReviewFeedback, (value, key) => {
const questionId = _.get(_.find(constants.scorecardQuestionMapping[message.payload.legacy.reviewScorecardId], item => _.toString(item.questionId) === _.toString(key) || _.toLower(item.description) === _.toLower(key)), 'questionId')
reviewResponses.push({
questionId,
answer: value
})
})
orReviewScore = _.toNumber(orReviewFeedback)
await legacyChallengeReviewService.insertReview(legacyId, message.payload.legacy.reviewScorecardId, orReviewScore, reviewResponses, createdByUserId)
}
}
}

if (message.payload.status && challenge) {
// Whether we need to sync v4 ES again
let needSyncV4ES = false
Expand Down Expand Up @@ -846,7 +788,7 @@ processMessage.schema = {
prizeSets: Joi.array().items(Joi.object().keys({
type: Joi.string().valid(_.values(constants.prizeSetTypes)).required(),
prizes: Joi.array().items(Joi.object().keys({
value: Joi.number().min(0).required()
value: Joi.number().positive().required()
}).unknown(true))
}).unknown(true)).min(1),
tags: Joi.array().items(Joi.string().required()).min(1), // tag names
Expand Down
124 changes: 0 additions & 124 deletions src/services/legacyChallengeReviewService.js

This file was deleted.

Loading