From e7ee6d0b4473aa50149126a206dc4900d3025833 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Tue, 11 Aug 2020 17:17:06 -0300 Subject: [PATCH 1/2] Fix Open For Review changes filter --- src/services/reviewOpportunities.js | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/services/reviewOpportunities.js b/src/services/reviewOpportunities.js index 51af9e44..820f5a46 100644 --- a/src/services/reviewOpportunities.js +++ b/src/services/reviewOpportunities.js @@ -8,19 +8,31 @@ import { getApi } from './api'; /** * Sync the fields of V3 and V5 for front-end to process successfully - * @param challenges - challenges to normalize + * @param opportunities - opportunities to normalize */ -export function normalizeChallenges(challenges) { - if (challenges) { - _.map(challenges, (ch) => { - const { challenge } = ch; - if (challenge.technologies && challenge.technologies.includes('Data Science')) { - challenge.track = 'DATA_SCIENCE'; +export function normalizeChallenges(opportunities) { + if (opportunities) { + /* Issue#4739 : Temporary add track to review opportunities challenges + * until receive API V5 update. */ + _.map(opportunities, (opportunity) => { + const { challenge } = opportunity; + challenge.track = 'Development'; + if (challenge.technologies) { + if (challenge.technologies.includes('Data Science')) { + challenge.track = 'Data Science'; + } else if (challenge.technologies.includes('QA')) { + challenge.track = 'Quality Assurance'; + } + } else if (challenge.subTrack === 'TEST_SUITES' || challenge.subTrack === 'BUG_HUNT') { + challenge.track = 'Quality Assurance'; + } else if (challenge.track === 'DESIGN') { + challenge.track = 'Design'; } - return _.defaults(ch, { challenge }); + return _.defaults(opportunity, { challenge }); }); } - return challenges; + + return opportunities; } /** From 477ccfebf66abec94167af297b44f1c6a9905d06 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Tue, 25 Aug 2020 05:03:04 -0300 Subject: [PATCH 2/2] Remove hard code tracks and subtracks --- __tests__/__snapshots__/index.js.snap | 10 ++++++++++ src/services/reviewOpportunities.js | 20 +++++++++++--------- src/utils/tc.js | 12 ++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 53d2317a..bf72ddb8 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -377,6 +377,16 @@ Object { "DEVELOP": "Development", "QA": "Quality Assurance", }, + "OLD_COMPETITION_TRACKS": Object { + "DATA_SCIENCE": "DATA_SCIENCE", + "DESIGN": "DESIGN", + "DEVELOP": "DEVELOP", + "QA": "QA", + }, + "OLD_SUBTRACKS": Object { + "BUG_HUNT": "BUG_HUNT", + "TEST_SUITES": "TEST_SUITES", + }, "REVIEW_OPPORTUNITY_TYPES": Object { "Contest Review": "Review", "Iterative Review": "Iterative Review", diff --git a/src/services/reviewOpportunities.js b/src/services/reviewOpportunities.js index 820f5a46..87f8dcd3 100644 --- a/src/services/reviewOpportunities.js +++ b/src/services/reviewOpportunities.js @@ -4,6 +4,7 @@ * submitting applications. */ import _ from 'lodash'; +import { COMPETITION_TRACKS, OLD_COMPETITION_TRACKS, OLD_SUBTRACKS } from 'utils/tc'; import { getApi } from './api'; /** @@ -16,17 +17,18 @@ export function normalizeChallenges(opportunities) { * until receive API V5 update. */ _.map(opportunities, (opportunity) => { const { challenge } = opportunity; - challenge.track = 'Development'; + challenge.track = COMPETITION_TRACKS.DEVELOP; if (challenge.technologies) { - if (challenge.technologies.includes('Data Science')) { - challenge.track = 'Data Science'; - } else if (challenge.technologies.includes('QA')) { - challenge.track = 'Quality Assurance'; + if (challenge.technologies.includes(COMPETITION_TRACKS.DATA_SCIENCE)) { + challenge.track = COMPETITION_TRACKS.DATA_SCIENCE; + } else if (challenge.technologies.includes(OLD_COMPETITION_TRACKS.QA)) { + challenge.track = COMPETITION_TRACKS.QA; } - } else if (challenge.subTrack === 'TEST_SUITES' || challenge.subTrack === 'BUG_HUNT') { - challenge.track = 'Quality Assurance'; - } else if (challenge.track === 'DESIGN') { - challenge.track = 'Design'; + } else if (challenge.subTrack === OLD_SUBTRACKS.TEST_SUITES + || challenge.subTrack === OLD_SUBTRACKS.BUG_HUNT) { + challenge.track = COMPETITION_TRACKS.QA; + } else if (challenge.track === OLD_COMPETITION_TRACKS.DESIGN) { + challenge.track = COMPETITION_TRACKS.DESIGN; } return _.defaults(opportunity, { challenge }); }); diff --git a/src/utils/tc.js b/src/utils/tc.js index 5388d4bb..28bcf3b2 100644 --- a/src/utils/tc.js +++ b/src/utils/tc.js @@ -17,6 +17,18 @@ export const COMPETITION_TRACKS = { QA: 'Quality Assurance', }; +export const OLD_COMPETITION_TRACKS = { + DATA_SCIENCE: 'DATA_SCIENCE', + DESIGN: 'DESIGN', + DEVELOP: 'DEVELOP', + QA: 'QA', +}; + +export const OLD_SUBTRACKS = { + TEST_SUITES: 'TEST_SUITES', + BUG_HUNT: 'BUG_HUNT', +}; + /** * Review Opportunity types */