Skip to content

Prod release #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 100 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
1b540ff
Allow closing pureV5 tasks without activation
ThomasKranitsas May 21, 2021
1815fdc
Merge pull request #415 from topcoder-platform/pureV5Tasks/activation
rootelement May 24, 2021
0c2461e
Merge branch 'master' into develop
May 24, 2021
3a1b710
Merge remote-tracking branch 'origin/develop' into develop
May 24, 2021
a385bf9
issue 416 fix]
Gauravseta May 27, 2021
c3c94d9
Merge pull request #419 from Gauravseta/issue-416
ThomasKranitsas May 27, 2021
d266b44
minor fixes on pureV5 flag
ThomasKranitsas May 27, 2021
4770676
update swagger and postman
ThomasKranitsas Jun 4, 2021
fd04800
documentation changes
ThomasKranitsas Jun 11, 2021
4fe35ce
Support winner.type
ThomasKranitsas Jun 14, 2021
4e30a53
Fix search issue - issue #425
ThomasKranitsas Jun 16, 2021
e3625d4
Do not populate actualEndDate automatically
ThomasKranitsas Jun 22, 2021
1d67c57
allow changing of timeline template ID on pureV5 challenges
ThomasKranitsas Jun 24, 2021
469b95f
make sure there are no previous phases if the timeline template has c…
ThomasKranitsas Jun 24, 2021
e9dc60b
Fix phases
ThomasKranitsas Jun 24, 2021
d357ee5
fix phases
ThomasKranitsas Jun 24, 2021
0a2359e
fix phases
ThomasKranitsas Jun 24, 2021
a517a2b
fix issue with dynamo/es sync on phases
ThomasKranitsas Aug 9, 2021
25a4eac
allow setting the actualEndDate to null
ThomasKranitsas Sep 1, 2021
ba90b64
check winners by type
ThomasKranitsas Sep 3, 2021
09c6e34
minor fix
ThomasKranitsas Sep 3, 2021
e610527
add endpoint for challenge statistics
ThomasKranitsas Dec 9, 2021
5a1dd4e
Merge pull request #438 from topcoder-platform/aggregate-mm-data
ThomasKranitsas Dec 9, 2021
79baf63
read from array instead of object
ThomasKranitsas Dec 9, 2021
472721b
Merge pull request #439 from topcoder-platform/aggregate-mm-data
ThomasKranitsas Dec 9, 2021
3d90d49
fix rating color
ThomasKranitsas Dec 10, 2021
cfaa104
Merge pull request #440 from topcoder-platform/aggregate-mm-data
ThomasKranitsas Dec 10, 2021
d8dd990
Performance fixes on groups
marioskranitsas Dec 22, 2021
9032e0b
Merge pull request #444 from topcoder-platform/feature/performance-fi…
ThomasKranitsas Dec 22, 2021
bf21f2c
fix groups check
ThomasKranitsas Dec 22, 2021
57395f3
selfService flag
marioskranitsas Jan 6, 2022
eb6f827
handle project changes for selfService
marioskranitsas Jan 6, 2022
5236179
manage payments for selfService
marioskranitsas Jan 6, 2022
7a8a036
Clean up and final touches on self-service challenges
ThomasKranitsas Jan 6, 2022
dfee724
add financial info to the project
ThomasKranitsas Jan 6, 2022
337aa1a
verify status of changed payments
ThomasKranitsas Jan 6, 2022
b98d12f
Get payments for reference: project
ThomasKranitsas Jan 7, 2022
2633116
Merge pull request #446 from topcoder-platform/feature/self-service-c…
ThomasKranitsas Jan 7, 2022
a92ab3a
make projectId optional
ThomasKranitsas Jan 10, 2022
0a022ef
pass m2m token if it's machine
ThomasKranitsas Jan 10, 2022
a35a188
read default timeline template with pagination
ThomasKranitsas Jan 10, 2022
fb0dec2
add logging
ThomasKranitsas Jan 10, 2022
543cc87
fix boolean with string comparison in challenge timelines
ThomasKranitsas Jan 10, 2022
1f0f468
Replace all description
marioskranitsas Jan 18, 2022
8e737e8
add logging'
ThomasKranitsas Jan 19, 2022
a697482
add missing await
ThomasKranitsas Jan 19, 2022
95b847f
temp fix on getting payment info
ThomasKranitsas Jan 19, 2022
feb22f4
try/catch
ThomasKranitsas Jan 19, 2022
ac218aa
logging
ThomasKranitsas Jan 19, 2022
f30870c
support legacy.selfServiceCopilot
ThomasKranitsas Jan 19, 2022
4d0fb0c
revert temp fix
ThomasKranitsas Jan 20, 2022
7d791c4
hot fix configs and add logging
ThomasKranitsas Jan 20, 2022
294b5e5
logging
ThomasKranitsas Jan 21, 2022
69e0732
udpate project name/description on activation
ThomasKranitsas Jan 21, 2022
76f68ca
use user handle instead of ID in the project name
ThomasKranitsas Jan 21, 2022
1ff7652
fix call to capture/cancel payment
ThomasKranitsas Jan 21, 2022
f8ea040
update payment info on activation/canceling of project
ThomasKranitsas Jan 21, 2022
d8019d6
dynamic template
ThomasKranitsas Jan 21, 2022
a7d95ef
fix dynamic spec
ThomasKranitsas Jan 21, 2022
199964a
use regex for dynamic spec
ThomasKranitsas Jan 21, 2022
e25ec76
support approved state for challenges
ThomasKranitsas Jan 21, 2022
d884897
Only allowe admins, m2m and whitelisted members to access selfService…
ThomasKranitsas Jan 23, 2022
3f773f6
fix
ThomasKranitsas Jan 23, 2022
5465abb
support adding forums post-creation
ThomasKranitsas Jan 24, 2022
4757f0c
fix typo
ThomasKranitsas Jan 24, 2022
a2af9fb
Temp fix for client manager role assigned to self-service challenge c…
jmgasper Jan 25, 2022
4ba7b6c
Merge pull request #450 from topcoder-platform/justin_client_manager_fix
jmgasper Jan 25, 2022
fd0df23
Update whitelisted copilots (temp for QA)
ThomasKranitsas Jan 26, 2022
8905871
v1 of email notifications for self-service
ThomasKranitsas Jan 26, 2022
797e66f
Merge branch 'develop' into feature/self-service-email
ThomasKranitsas Jan 26, 2022
9e9916a
Merge pull request #451 from topcoder-platform/feature/self-service-e…
ThomasKranitsas Jan 26, 2022
89d8b0e
fix access checks
ThomasKranitsas Jan 26, 2022
768a174
Merge branch 'feature/self-service-email' of https://github.com/topco…
ThomasKranitsas Jan 26, 2022
c04adfb
Merge pull request #452 from topcoder-platform/feature/self-service-e…
ThomasKranitsas Jan 26, 2022
106e1d9
Fix submitted email
ThomasKranitsas Jan 26, 2022
7e14aa0
only send email on activation
ThomasKranitsas Jan 26, 2022
540df6a
Merge pull request #453 from topcoder-platform/feature/self-service-e…
ThomasKranitsas Jan 26, 2022
5d7057f
submission vs activation email
ThomasKranitsas Jan 26, 2022
4230791
fix recipient to be the creator of the challenge
ThomasKranitsas Jan 26, 2022
c16ede2
all types of email notifications
ThomasKranitsas Jan 26, 2022
8445b19
fix undefined in project name
ThomasKranitsas Jan 26, 2022
fe69484
add cancelReason
ThomasKranitsas Jan 26, 2022
0f8f3d1
fix issue with challenge updates
ThomasKranitsas Jan 26, 2022
e46615c
Add endpoint for submitting requests to zendesk
ThomasKranitsas Jan 27, 2022
458a70e
properly format request body for zendesk
ThomasKranitsas Jan 27, 2022
e5e65a8
support custom self_service tag on zendesk requests
ThomasKranitsas Jan 27, 2022
bad7d7c
auto activate project after reviewed
ThomasKranitsas Jan 27, 2022
162121f
correct project status
ThomasKranitsas Jan 27, 2022
7eee377
allow null for selfServiceCopilot
ThomasKranitsas Jan 30, 2022
1dcf9a0
add support URL to email data
ThomasKranitsas Jan 30, 2022
1384554
make /challenges/support-requests public
ThomasKranitsas Jan 30, 2022
150bdc3
add a QA email for testing on cc
ThomasKranitsas Jan 31, 2022
b12a4af
performance improvements and fix access checks on self service challe…
ThomasKranitsas Feb 1, 2022
90882b4
fix issue with copilots not being able to approve SS challenges and c…
ThomasKranitsas Feb 2, 2022
68258c7
implement endpoint to trigger notifications
ThomasKranitsas Feb 3, 2022
6594f8b
Merge branch 'master' into develop
ThomasKranitsas Feb 3, 2022
85b7ce0
add priority on zendesk requests
ThomasKranitsas Feb 3, 2022
60212d2
Merge branch 'develop' of https://github.com/topcoder-platform/challe…
ThomasKranitsas Feb 3, 2022
713e041
config clean up
ThomasKranitsas Feb 3, 2022
5c6d279
parse whitelisted handles
ThomasKranitsas Feb 3, 2022
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
100 changes: 66 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,50 +81,82 @@ You can find sample `.env` files inside the `/docs` directory.
5. View table data in default environment: `npm run view-data <ModelName>`, ModelName can be `Challenge`, `ChallengeType`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment`
6. Create Elasticsearch index: `npm run init-es`, or to re-create index: `npm run init-es force`
7. Synchronize ES data and DynamoDB data: `npm run sync-es`
8. Start all the depending services for local deployment: `npm run services:up`
9. Stop all the depending services for local deployment: `npm run services:down`
10. Check the logs of all the depending services for local deployment: `npm run services:logs`
11. Initialize the local environments: `npm run local:init`
12. Reset the local environments: `npm run local:reset`


### Notes
- The seed data are located in `src/scripts/seed`

## Local Deployment
0. Make sure to use Node v10+ by command `node -v`. We recommend using [NVM](https://github.com/nvm-sh/nvm) to quickly switch to the right version:

```bash
nvm use
```

1. 📦 Install npm dependencies

```bash
npm install
```

2. ⚙ Local config
In the `challenge-api` root directory create `.env` file with the next environment variables. Values for **Auth0 config** should be shared with you on the forum.<br>
```bash
# Auth0 config
AUTH0_URL=
AUTH0_PROXY_SERVER_URL=
AUTH0_AUDIENCE=
AUTH0_CLIENT_ID=
AUTH0_CLIENT_SECRET=

# Locally deployed services (via docker-compose)
IS_LOCAL_DB=true
DYNAMODB_URL=http://localhost:8000
```

- Values from this file would be automatically used by many `npm` commands.
- ⚠️ Never commit this file or its copy to the repository!

3. 🚢 Start docker-compose with services which are required to start Topcoder Challenges API locally

```bash
npm run services:up
```

4. ♻ Update following two parts:
- https://github.com/topcoder-platform/challenge-api/blob/develop/src/models/Challenge.js#L116
`throughput: 'ON_DEMAND',` should be updated to `throughput:{ read: 4, write: 2 },`
- https://github.com/topcoder-platform/challenge-api/blob/develop/config/default.js#L27-L28

### AWS S3 Setup
Go to https://console.aws.amazon.com/ and login. Choose S3 from Service folder and click `Create bucket`. Following the instruction to create S3 bucket.
5. ♻ Create tables.

### Local services setup
In the `local` folder, run `docker-compose up` to start Elasticsearch, DynamoDB, S3 compatible server and Mock API.
```bash
npm run create-tables
# Use `npm run drop-tables` to drop tables.
```

### Create Tables
1. Make sure DynamoDB are running as per instructions above.
2. Make sure you have configured all config parameters. Refer [Configuration](#configuration)
3. Run `npm run create-tables` to create tables.
6. ♻ Init DB, ES

### Mock API
The provided mock API provides mock endpoint to fetch challenge resources and groups so you don't have to deploy the related services locally.
You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js`
Mock API starts after running `docker-compose up` and expose port 4000.
```bash
npm run local:init
```

### Notes
There are two parts need to be updated for local development
- https://github.com/topcoder-platform/challenge-api/blob/develop/src/models/Challenge.js#L116
`throughput: 'ON_DEMAND',` should be updated to `throughput:{ read: 4, write: 2 },`
- https://github.com/topcoder-platform/challenge-api/blob/develop/config/default.js#L27-L28
Two aws config should be uncommented

and AUTH0 related configuration must be set at config file or in env variables.

### Deploy the app

- Follow the Notes section above
- Install dependencies `npm install`
- Run lint `npm run lint`
- Run lint fix `npm run lint:fix`
- initialize Elasticsearch, create configured Elasticsearch index if not present: `npm run init-es`,
or re-create the index: `npm run init-es force`
- Create tables `npm run create-tables`
- Clear and init db `npm run init-db`
- Seed tables: `npm run seed-tables`
- Start app `npm start`
- App is running at `http://localhost:3000`
This command will do 3 things:
- create Elasticsearch indexes (drop if exists)
- Initialize the database by cleaning all the records.
- Import the data to the local database and index it to ElasticSearch

7. 🚀 Start Topcoder Challenge API

```bash
npm start
```
The Topcoder Challenge API will be served on `http://localhost:3000`

## Production deployment

Expand Down
13 changes: 8 additions & 5 deletions Verification.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# TopCoder Challenge API Verification

## Postman tests
- clear the environment, run command `npm run init-db` and `npm run init-es force`
- import Postman collection and environment in the docs folder to Postman
- run tests from up to down in order
- You need to run command `npm run sync-es` before you run `Challenges/get challenge` and `Challenges/search challenge` test case.
## E2E Postman tests
- Import Postman collection and environment in the docs folder to Postman
- Set `token` variable in environment variables folder
- Open Runner
- Put E2E Test Folder inside Runner
- Set `Delay` to 2000ms
- Check `Save Responses`
- Start Run

## DynamoDB Verification
Run command `npm run view-data <ModelName>` to view table data, ModelName can be `Challenge`, `ChallengeType`, `AuditLog`, `Phase`, `TimelineTemplate`, `Attachment` or `ChallengeTimelineTemplate`
Expand Down
43 changes: 39 additions & 4 deletions app-constants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const config = require('config')

/**
* App constants
*/
const UserRoles = {
Admin: 'administrator',
Copilot: 'copilot',
Manager: 'Connect Manager',
User: 'Topcoder User'
User: 'Topcoder User',
SelfServiceCustomer: 'Self-Service Customer'
}

const prizeSetTypes = {
Expand All @@ -18,6 +21,7 @@ const prizeSetTypes = {
const challengeStatuses = {
New: 'New',
Draft: 'Draft',
Approved: 'Approved',
Cancelled: 'Cancelled',
Active: 'Active',
Completed: 'Completed',
Expand All @@ -28,7 +32,8 @@ const challengeStatuses = {
CancelledWinnerUnresponsive: 'Cancelled - Winner Unresponsive',
CancelledClientRequest: 'Cancelled - Client Request',
CancelledRequirementsInfeasible: 'Cancelled - Requirements Infeasible',
CancelledZeroRegistrations: 'Cancelled - Zero Registrations'
CancelledZeroRegistrations: 'Cancelled - Zero Registrations',
CancelledPaymentFailed: 'Cancelled - Payment Failed'
}

const validChallengeParams = {
Expand Down Expand Up @@ -70,7 +75,9 @@ const Topics = {
ChallengeTypeTimelineTemplateDeleted: 'test.new.bus.events', // 'challenge.action.type.timeline.template.deleted'
ChallengeAttachmentCreated: 'test.new.bus.events', // 'challenge.action.attachment.created',
ChallengeAttachmentUpdated: 'test.new.bus.events', // 'challenge.action.attachment.updated',
ChallengeAttachmentDeleted: 'test.new.bus.events' // 'challenge.action.attachment.deleted',
ChallengeAttachmentDeleted: 'test.new.bus.events', // 'challenge.action.attachment.deleted',
// Self Service topics
Notifications: 'notifications.action.create'
}

const challengeTracks = {
Expand All @@ -90,6 +97,32 @@ const reviewTypes = {
Internal: 'INTERNAL'
}

const SelfServiceNotificationTypes = {
WORK_REQUEST_SUBMITTED: 'self-service.notifications.work-request-submitted',
WORK_REQUEST_STARTED: 'self-service.notifications.work-request-started',
WORK_REQUEST_REDIRECTED: 'self-service.notifications.work-request-redirected',
WORK_COMPLETED: 'self-service.notifications.work-completed'
}

const SelfServiceNotificationSettings = {
[SelfServiceNotificationTypes.WORK_REQUEST_SUBMITTED]: {
sendgridTemplateId: config.SENDGRID_TEMPLATES.WORK_REQUEST_SUBMITTED,
cc: []
},
[SelfServiceNotificationTypes.WORK_REQUEST_STARTED]: {
sendgridTemplateId: config.SENDGRID_TEMPLATES.WORK_REQUEST_STARTED,
cc: []
},
[SelfServiceNotificationTypes.WORK_REQUEST_REDIRECTED]: {
sendgridTemplateId: config.SENDGRID_TEMPLATES.WORK_REQUEST_REDIRECTED,
cc: [...config.SELF_SERVICE_EMAIL_CC_ACCOUNTS]
},
[SelfServiceNotificationTypes.WORK_COMPLETED]: {
sendgridTemplateId: config.SENDGRID_TEMPLATES.WORK_COMPLETED,
cc: []
}
}

module.exports = {
UserRoles,
prizeSetTypes,
Expand All @@ -101,5 +134,7 @@ module.exports = {
challengeTracks,
challengeTextSortField,
DiscussionTypes,
reviewTypes
reviewTypes,
SelfServiceNotificationTypes,
SelfServiceNotificationSettings
}
1 change: 1 addition & 0 deletions app-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = (app) => {
next(new errors.ForbiddenError('You are not allowed to perform this action!'))
} else {
req.authUser.handle = config.M2M_AUDIT_HANDLE
req.userToken = req.headers.authorization.split(' ')[1]
next()
}
} else {
Expand Down
26 changes: 24 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* The configuration file.
*/

const _ = require('lodash')
require('dotenv').config()
module.exports = {
READONLY: process.env.READONLY === 'true' || false,
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
Expand Down Expand Up @@ -57,13 +58,15 @@ module.exports = {
GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups',
PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v5/projects',
TERMS_API_URL: process.env.TERMS_API_URL || 'http://localhost:4000/v5/terms',
CUSTOMER_PAYMENTS_URL: process.env.CUSTOMER_PAYMENTS_URL || 'https://api.topcoder-dev.com/v5/customer-payments',
// copilot resource role ids allowed to upload attachment
COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS
? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'],
SUBMITTER_ROLE_ID: process.env.SUBMITTER_ROLE_ID || '732339e7-8e30-49d7-9198-cccf9451e221',

MANAGER_ROLE_ID: process.env.MANAGER_ROLE_ID || '0e9c6879-39e4-4eb6-b8df-92407890faf1',
OBSERVER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '2a4dc376-a31c-4d00-b173-13934d89e286',
CLIENT_MANAGER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '9b2f1905-8128-42da-85df-ed64410f4781',

// health check timeout in milliseconds
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,
Expand All @@ -80,5 +83,24 @@ module.exports = {

M2M_AUDIT_HANDLE: process.env.M2M_AUDIT_HANDLE || 'tcwebservice',

FORUM_TITLE_LENGTH_LIMIT: process.env.FORUM_TITLE_LENGTH_LIMIT || 90
FORUM_TITLE_LENGTH_LIMIT: process.env.FORUM_TITLE_LENGTH_LIMIT || 90,

NEW_SELF_SERVICE_PROJECT_TYPE: process.env.NEW_SELF_SERVICE_PROJECT_TYPE || 'self-service',

SENDGRID_TEMPLATES: {
WORK_REQUEST_SUBMITTED: process.env.WORK_REQUEST_SUBMITTED || '',
WORK_REQUEST_STARTED: process.env.WORK_REQUEST_STARTED || '',
WORK_REQUEST_REDIRECTED: process.env.WORK_REQUEST_REDIRECTED || '',
WORK_COMPLETED: process.env.WORK_COMPLETED || ''
},

EMAIL_FROM: process.env.EMAIL_FROM || 'no-reply@topcoder.com',
SELF_SERVICE_EMAIL_CC_ACCOUNTS: process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS ? _.map(process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS.split(','), email => ({ email })) : ['sathya.jayabal@gmail.com'],
SELF_SERVICE_WHITELIST_HANDLES: process.env.SELF_SERVICE_WHITELIST_HANDLES ? process.env.SELF_SERVICE_WHITELIST_HANDLES.split(',') : ['TCConnCopilot', 'sstestcopilot'],
SELF_SERVICE_APP_URL: process.env.SELF_SERVICE_APP_URL || 'https://platform.topcoder-dev.com/self-service',

ZENDESK_API_TOKEN: process.env.ZENDESK_API_TOKEN || '',
ZENDESK_API_URL: process.env.ZENDESK_API_URL || '',
ZENDESK_CUSTOM_FIELD_TAG_ID: process.env.ZENDESK_CUSTOM_FIELD_TAG_ID,
ZENDESK_DEFAULT_PRIORITY: process.env.ZENDESK_DEFAULT_PRIORITY || 'high'
}
Loading