Skip to content

Commit cf45aa4

Browse files
authored
Merge pull request #642 from topcoder-platform/dev
feat: add phase transition functionality
2 parents 7af1de2 + a4bb399 commit cf45aa4

File tree

13 files changed

+1918
-291
lines changed

13 files changed

+1918
-291
lines changed

.circleci/config.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ install_deploysuite: &install_deploysuite
1717
cp ./../buildscript/master_deploy.sh .
1818
cp ./../buildscript/buildenv.sh .
1919
cp ./../buildscript/awsconfiguration.sh .
20+
2021
restore_cache_settings_for_build: &restore_cache_settings_for_build
2122
key: docker-node-modules-{{ checksum "yarn.lock" }}
2223

@@ -32,8 +33,14 @@ builddeploy_steps: &builddeploy_steps
3233
- run: *install_deploysuite
3334
- restore_cache: *restore_cache_settings_for_build
3435
- run:
35-
name: "Authenticate with CodeArtifact and build docker image"
36-
command: "./awsconfiguration.sh ${CODEARTIFACT_ENV}\nsource awsenvconf\naws codeartifact login --tool npm --repository topcoder-framework --domain topcoder --domain-owner $AWS_ACCOUNT_ID --region $AWS_REGION --namespace @topcoder-framework\ncp ~/.npmrc .\nrm -f awsenvconf \n./build.sh ${APPNAME}\n"
36+
name: "Authenticate with CodeArtifact and build Docker image"
37+
command: |
38+
./awsconfiguration.sh ${CODEARTIFACT_ENV}
39+
source awsenvconf
40+
aws codeartifact login --tool npm --repository topcoder-framework --domain topcoder --domain-owner $AWS_ACCOUNT_ID --region $AWS_REGION --namespace @topcoder-framework
41+
cp ~/.npmrc .
42+
rm -f awsenvconf
43+
./build.sh ${APPNAME}
3744
- save_cache: *save_cache_settings
3845
- deploy:
3946
name: Running MasterScript.
@@ -83,7 +90,7 @@ workflows:
8390
branches:
8491
only:
8592
- dev
86-
- fix/plat-2985
93+
- feature/phase-advance
8794

8895
- "build-qa":
8996
context: org-global

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"dependencies": {
4343
"@grpc/grpc-js": "^1.8.12",
4444
"@opensearch-project/opensearch": "^2.2.0",
45-
"@topcoder-framework/domain-challenge": "^0.10.14",
46-
"@topcoder-framework/lib-common": "^0.10.14",
45+
"@topcoder-framework/domain-challenge": "^0.18.0",
46+
"@topcoder-framework/lib-common": "^0.18.0",
4747
"aws-sdk": "^2.1145.0",
4848
"axios": "^0.19.0",
4949
"axios-retry": "^3.4.0",
@@ -53,6 +53,7 @@
5353
"cors": "^2.8.5",
5454
"decimal.js": "^10.4.3",
5555
"deep-equal": "^2.2.0",
56+
"dompurify": "^3.0.2",
5657
"dotenv": "^8.2.0",
5758
"elasticsearch": "^16.7.3",
5859
"express": "^4.15.4",
@@ -62,8 +63,11 @@
6263
"http-aws-es": "^6.0.0",
6364
"http-status-codes": "^1.3.0",
6465
"joi": "^14.0.0",
66+
"jsdom": "^21.1.2",
67+
"json-rules-engine": "^6.1.2",
6568
"jsonwebtoken": "^8.3.0",
6669
"lodash": "^4.17.19",
70+
"markdown-it": "^13.0.1",
6771
"moment": "^2.24.0",
6872
"node-cache": "^5.1.2",
6973
"swagger-ui-express": "^4.1.3",

src/common/helper.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,18 @@ async function deleteFromS3(bucket, key) {
226226
* @param {String} challengeId the challenge id
227227
* @returns {Promise<Array>} the challenge resources
228228
*/
229-
async function getChallengeResources(challengeId) {
229+
async function getChallengeResources(challengeId, roleId = null) {
230230
const token = await m2mHelper.getM2MToken();
231231
const perPage = 100;
232232
let page = 1;
233233
let result = [];
234234
while (true) {
235-
const url = `${config.RESOURCES_API_URL}?challengeId=${challengeId}&perPage=${perPage}&page=${page}`;
235+
const url = `${
236+
config.RESOURCES_API_URL
237+
}?challengeId=${challengeId}&perPage=${perPage}&page=${page}${
238+
roleId ? `&roleId=${roleId}` : ""
239+
}`;
240+
236241
const res = await axios.get(url, {
237242
headers: { Authorization: `Bearer ${token}` },
238243
});
@@ -1020,7 +1025,7 @@ async function getGroupById(groupId) {
10201025
/**
10211026
* Get challenge submissions
10221027
* @param {String} challengeId the challenge id
1023-
* @returns {Array} the submission
1028+
* @returns {Promise<Array>} the submission
10241029
*/
10251030
async function getChallengeSubmissions(challengeId) {
10261031
const token = await m2mHelper.getM2MToken();

src/common/phase-helper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const phaseDomain = new PhaseDomain(GRPC_CHALLENGE_SERVER_HOST, GRPC_CHALLENGE_S
2020
class ChallengePhaseHelper {
2121
phaseDefinitionMap = {};
2222
timelineTemplateMap = {};
23+
2324
async populatePhasesForChallengeCreation(phases, startDate, timelineTemplateId) {
2425
if (_.isUndefined(timelineTemplateId)) {
2526
throw new errors.BadRequestError(`Invalid timeline template ID: ${timelineTemplateId}`);
@@ -176,7 +177,10 @@ class ChallengePhaseHelper {
176177

177178
handlePhasesAfterCancelling(phases) {
178179
return _.map(phases, (phase) => {
179-
const shouldClosePhase = _.includes(["Registration", "Submission", "Checkpoint Submission"], phase.name);
180+
const shouldClosePhase = _.includes(
181+
["Registration", "Submission", "Checkpoint Submission"],
182+
phase.name
183+
);
180184
return {
181185
...phase,
182186
isOpen: shouldClosePhase ? false : phase.isOpen,

src/controllers/ChallengeController.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ async function deleteChallenge(req, res) {
116116
res.send(result);
117117
}
118118

119+
/**
120+
* Advance phase
121+
* @param {Object} req the request
122+
* @param {Object} res the response
123+
*/
124+
async function advancePhase(req, res) {
125+
res.send(await service.advancePhase(req.authUser, req.params.challengeId, req.body));
126+
}
127+
119128
module.exports = {
120129
searchChallenges,
121130
createChallenge,
@@ -124,4 +133,5 @@ module.exports = {
124133
deleteChallenge,
125134
getChallengeStatistics,
126135
sendNotifications,
136+
advancePhase,
127137
};

0 commit comments

Comments
 (0)