Skip to content

Commit 82db802

Browse files
author
sachin-maheshwari
authored
Merge pull request #225 from topcoder-platform/develop
Shapeup-pure-v5-tasks v3
2 parents daa7453 + 11f64d0 commit 82db802

24 files changed

+1427
-1064
lines changed

.circleci/config.yml

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
version: 2
22
defaults: &defaults
33
docker:
4-
- image: docker:18.06.0-ce-git
4+
- image: circleci/python:stretch-browsers
55
install_dependency: &install_dependency
6-
name: Installation of build and deployment dependencies.
7-
command: |
8-
apk update
9-
apk add --no-cache bash
10-
apk add --no-cache jq py-pip sudo curl
11-
apk upgrade
12-
apk add py-pip python-dev libffi-dev openssl-dev gcc libc-dev make
13-
pip install --upgrade pip
14-
sudo pip install awscli --upgrade
15-
sudo curl -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest
16-
sudo pip install docker-compose
17-
sudo chmod +x /usr/local/bin/ecs-cli
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip3 install awscli --upgrade
10+
sudo pip3 install docker-compose
1811
1912
install_deploysuite: &install_deploysuite
2013
name: Installation of install_deploysuite.
2114
command: |
22-
git clone --branch v1.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
git clone --branch v1.4.1 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
2316
cp ./../buildscript/master_deploy.sh .
2417
cp ./../buildscript/buildenv.sh .
2518
cp ./../buildscript/awsconfiguration.sh .
@@ -79,4 +72,4 @@ workflows:
7972
context : org-global
8073
filters:
8174
branches:
82-
only: master
75+
only: master

README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ Please ensure to create the index `submission-test` or the index specified in th
135135
export ES_INDEX=submission-test
136136
```
137137

138-
139138
#### Running unit tests and coverage
140139

141140
To run unit tests alone
@@ -172,6 +171,26 @@ To migrate the existing data from DynamoDB to ES, run the following script
172171
npm run db-to-es
173172
```
174173

174+
#### Store v5 challenge id for current records
175+
176+
Submission API started off using the legacy challenge ids. With the v5 upgrade to the challenge api, we now need to make use of the v5 challenge ids. We have thus created a script to update existing `challengeId` attribute on submissions to v5 and store the older challenge ids in the `legacyChallengeId` attribute.
177+
178+
To update the existing challengeId data on submissions in DynamoDB to v5 challengeId, set the following env variables:
179+
180+
```bash
181+
SUBMISSION_TABLE_NAME // Table name of the submission records. Defaults to 'Submission'
182+
UPDATE_V5_CHALLENGE_BATCH_SIZE // Number of records that are updated simultaneously. Defaults to 250
183+
FETCH_CREATED_DATE_START // The start day of fetch latest challenges. Defaults to '2021-01-01'
184+
FETCH_PAGE_SIZE // The page size of each api request. Defaults to 500
185+
```
186+
187+
188+
and then run the following script
189+
190+
```
191+
npm run update-to-v5-challengeId
192+
```
193+
175194
#### Swagger UI
176195

177196
Swagger UI will be served at `http://localhost:3000/docs`

config/default.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module.exports = {
2121
BUSAPI_URL: process.env.BUSAPI_URL || 'https://api.topcoder-dev.com/v5',
2222
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'error.notification',
2323
KAFKA_AGGREGATE_TOPIC: process.env.KAFKA_AGGREGATE_TOPIC || 'submission.notification.aggregate',
24-
CHALLENGEAPI_URL: process.env.CHALLENGEAPI_URL || 'https://api.topcoder-dev.com/v4/challenges',
2524
CHALLENGEAPI_V5_URL: process.env.CHALLENGEAPI_V5_URL || 'https://api.topcoder-dev.com/v5/challenges',
25+
RESOURCEAPI_V5_BASE_URL: process.env.RESOURCEAPI_V5_BASE_URL || 'https://api.topcoder-dev.com/v5',
2626
AUTH0_URL: process.env.AUTH0_URL, // Auth0 credentials for Submission Service
2727
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://www.topcoder.com',
2828
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME,
@@ -37,5 +37,9 @@ module.exports = {
3737
PAGE_SIZE: process.env.PAGE_SIZE || 20,
3838
MAX_PAGE_SIZE: parseInt(process.env.MAX_PAGE_SIZE) || 100,
3939
ES_BATCH_SIZE: process.env.ES_BATCH_SIZE || 250,
40-
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL
40+
UPDATE_V5_CHALLENGE_BATCH_SIZE: process.env.UPDATE_V5_CHALLENGE_BATCH_SIZE || 100,
41+
SUBMISSION_TABLE_NAME: process.env.SUBMISSION_TABLE_NAME || 'Submission',
42+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,
43+
FETCH_CREATED_DATE_START: process.env.FETCH_CREATED_DATE_START || '2021-01-01',
44+
FETCH_PAGE_SIZE: process.env.FETCH_PAGE_SIZE || 500
4145
}

config/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
LOG_LEVEL: 'info',
88
WEB_SERVER_PORT: 3010,
99
AUTH_SECRET: 'mysecret',
10-
VALID_ISSUERS: '["https://api.topcoder.com"]',
10+
VALID_ISSUERS: process.env.VALID_ISSUERS ? process.env.VALID_ISSUERS.replace(/\\"/g, '') : '["https://api.topcoder.com","https://topcoder-dev.auth0.com/"]',
1111
API_VERSION: process.env.API_VERSION || '/api/v5',
1212
aws: {
1313
AWS_REGION: process.env.AWS_REGION || 'us-east-1', // AWS Region to be used by the application
@@ -16,14 +16,14 @@ module.exports = {
1616
S3_BUCKET: process.env.S3_BUCKET_TEST || 'tc-testing-submissions' // S3 Bucket to which submissions need to be uploaded
1717
},
1818
BUSAPI_EVENTS_URL: 'https://api.topcoder-dev.com/v5/bus/events',
19-
CHALLENGEAPI_URL: 'https://api.topcoder-dev.com/v4/challenges',
19+
BUSAPI_URL: 'https://api.topcoder-dev.com/v5',
20+
CHALLENGEAPI_V5_URL: 'https://api.topcoder-dev.com/v5/challenges',
2021
esConfig: {
2122
ES_INDEX: process.env.ES_INDEX_TEST || 'submission-test',
2223
ES_TYPE: process.env.ES_TYPE_TEST || '_doc' // ES 6.x accepts only 1 Type per index and it's mandatory to define it
2324
},
2425
AUTH0_URL: process.env.AUTH0_URL, // Auth0 credentials for Submission Service
25-
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://www.topcoder.com',
26-
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME,
26+
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE,
2727
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
2828
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
2929
USER_TOKEN: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLmNvbSIsImhhbmRsZSI6IlNoYXJhdGhrdW1hcjkyIiwiZXhwIjo1NTUzMDE5OTI1OSwidXNlcklkIjoiNDA0OTMwNTAiLCJpYXQiOjE1MzAxOTg2NTksImVtYWlsIjoiU2hhcmF0aGt1bWFyOTJAdG9wY29kZXIuY29tIiwianRpIjoiYzNhYzYwOGEtNTZiZS00NWQwLThmNmEtMzFmZTk0Yjk1NjFjIn0.2gtNJwhcv7MYc-muX3Nv-B0RdWbhMRl7-xrwFUsLazM',

docs/swagger.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ paths:
9595
legacySubmissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0502'
9696
legacyUploadId: 'a12a4180-65aa-42ec-a945-5fd21dec0502'
9797
submissionPhaseId: 764567
98+
submittedDate: '2018-05-20T07:00:30.123Z'
9899
created: '2018-05-20T07:00:30.123Z'
99100
updated: '2018-06-01T07:36:28.178Z'
100101
createdBy: 'topcoder user'
@@ -107,6 +108,7 @@ paths:
107108
legacySubmissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0502'
108109
legacyUploadId: 'a12a4180-65aa-42ec-a945-5fd21dec0502'
109110
submissionPhaseId: 764567
111+
submittedDate: '2018-05-20T08:00:30.000Z'
110112
created: '2018-05-20T08:00:30.000Z'
111113
updated: '2018-06-01T09:23:00.178Z'
112114
createdBy: 'topcoder user'
@@ -205,6 +207,7 @@ paths:
205207
Create a new submission.
206208
207209
**Authorization:** Submission creation is accessible by roles `topcoder user`, `admin` and `copilot`.
210+
**Note** Value for `submittedDate` attribute can only be provided by users with `admin` role
208211
tags:
209212
- Submissions
210213
operationId: createSubmission
@@ -262,6 +265,11 @@ paths:
262265
name: submissionPhaseId
263266
type: integer
264267
description: Submission Phase Id
268+
- in: formData
269+
name: submittedDate
270+
type: string
271+
format: date-time
272+
description: Date of submission (defaults to submission creation date if none passed)
265273
responses:
266274
201:
267275
description: Created - The request was successful and the resource is returned.
@@ -612,6 +620,7 @@ paths:
612620
scoreCardId: 123456789
613621
isPassing: false
614622
isFinal: false
623+
reviewedDate: '2018-05-20T07:00:30.123Z'
615624
created: '2018-05-20T07:00:30.123Z'
616625
updated: '2018-06-01T07:36:28.178Z'
617626
createdBy: copilot
@@ -622,6 +631,7 @@ paths:
622631
scoreCardId: 123456789
623632
isPassing: true
624633
isFinal: true
634+
reviewedDate: '2018-05-20T07:00:30.123Z'
625635
created: '2018-05-20T07:00:30.123Z'
626636
updated: '2018-06-01T07:36:28.178Z'
627637
createdBy: copilot
@@ -718,6 +728,8 @@ paths:
718728
Create a new review summation.
719729
720730
**Authorization:** Review summation creation is accessible by roles `admin` and `copilot`.
731+
732+
**Note** Value for `reviewedDate` attribute can only be provided by users with `admin` role
721733
tags:
722734
- 'Review summations'
723735
operationId: createReviewSummation
@@ -931,6 +943,7 @@ paths:
931943
scoreCardId: 123456789
932944
submissionId: 'd67a4180-65aa-42ec-a945-5fd21dec0503'
933945
status: 'queued'
946+
reviewedDate: '2018-05-20T07:00:30.123Z'
934947
created: '2018-05-20T07:00:30.123Z'
935948
updated: '2018-06-01T07:36:28.178Z'
936949
createdBy: 'admin'
@@ -942,6 +955,7 @@ paths:
942955
scoreCardId: 123456789
943956
submissionId: 'd23a4180-65aa-42ec-a945-5fd21dec0503'
944957
status: 'completed'
958+
reviewedDate: '2018-05-20T07:00:30.123Z'
945959
created: '2018-05-20T07:00:30.123Z'
946960
updated: '2018-06-01T07:36:28.178Z'
947961
createdBy: 'admin'
@@ -1038,6 +1052,8 @@ paths:
10381052
Create a new review.
10391053
10401054
**Authorization:** Review creation is accessible by roles `admin` and `copilot`.
1055+
1056+
**Note** Value for `reviewedDate` attribute can only be provided by users with `admin` role
10411057
tags:
10421058
- 'Reviews'
10431059
operationId: createReview
@@ -1880,6 +1896,11 @@ definitions:
18801896
type: integer
18811897
description: The submission phase id.
18821898
example: '5dea6d9e-161a-4c7a-b316-597c73a7b8f4'
1899+
submittedDate:
1900+
type: string
1901+
format: date-time
1902+
description: Date of submission (defaults to submission creation date if none passed)
1903+
example: '2018-05-20T07:00:30.123Z'
18831904

18841905
UpdatableSubmission:
18851906
description: The submission entity fields that updates whole entity.
@@ -1939,6 +1960,11 @@ definitions:
19391960
metadata:
19401961
type: object
19411962
description: Review summation metadata in JSON format
1963+
reviewedDate:
1964+
type: string
1965+
format: date-time
1966+
description: Date of review summation (defaults to review summation creation date if none passed)
1967+
example: '2018-05-20T07:00:30.123Z'
19421968

19431969
UpdatableReviewSummation:
19441970
description: The review summation entity fields that updates whole entity.
@@ -2006,6 +2032,11 @@ definitions:
20062032
metadata:
20072033
type: object
20082034
description: Review Metadata in JSON format
2035+
reviewedDate:
2036+
type: string
2037+
format: date-time
2038+
description: Date of review (defaults to review creation date if none passed)
2039+
example: '2018-05-20T07:00:30.123Z'
20092040

20102041
UpdatableReview:
20112042
description: The review entity fields that updates whole entity.

0 commit comments

Comments
 (0)