Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ jspm_packages
.DS_Store
.idea
.vscode/


.nyc_output
33 changes: 33 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ These commands will set auth0 and event bus api to local mock server.
## Local Deployment

- Make sure you have started db and set `DATABASE_URL`.
- To easily, configure local env variables, update `local.env.sh` and execute it using `source local.env.sh`.
- Make sure you have create db structure. Seed data is optional.
- Install dependencies `npm install`
- Start app `npm start`
Expand All @@ -171,12 +172,44 @@ Make sure you have followed above steps to
- setup db and config db url
- setup local mock api and set local configs
- it will really call service and mock api
- Run postgres database (check above for details)
- Download Seed data.
```bash
node src/scripts/download.js
```


- Create DB and Run seeds.


```bash
# create db tables
npm run init-db


node src/scripts/seed-data.js
```

### Unit tests
Then you can run:
```bash
npm run test
```

To create coverage report
```bash
npm run test:cov
```

### E2E tests
```bash
npm run e2e
```

To create coverage report
```bash
npm run e2e:cov
```

## Verification
Refer to the verification document `Verification.md`
32 changes: 23 additions & 9 deletions config/test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions local.env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export NODE_ENV=test
export AUTH0_URL="http://localhost:4000/v5/auth0"
export BUSAPI_URL="http://localhost:4000/v5"
export AUTH0_CLIENT_ID=xyz
export AUTH0_CLIENT_SECRET=xyz
export USERFLOW_PRIVATE_KEY=mysecret
export GROUPS_API_URL="http://localhost:4000/v5/groups"
export DATABASE_URL="postgresql://johndoe:mypassword@localhost:5432/memberdb"
export LOG_LEVEL=silent
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"reset-db": "prisma migrate reset",
"test": "mocha -t 20000 test/unit/*.test.js --exit",
"test:cov": "nyc --reporter=html --reporter=text npm test",

"e2e": "mocha test/e2e/*.test.js --exit --reporter spec --bail",
"e2e:cov": "nyc --all --eager --include=\"src/**/*.js\" --include=\"app*.js\" --include=\"config/**/*.js\" --exclude=\"test/**/*.js\" --reporter=html --reporter=text --reporter=text-summary mocha test/e2e/*.test.js --exit --reporter spec --bail",

"migrate-dynamo-data": "node src/scripts/migrate-dynamo-data.js"
},
"author": "TCSCODER",
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/seed-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ function buildDevelopStatsData (jsonData) {
const itemData = jsonData.subTracks
const items = _.map(itemData, t => ({
name: t.name,
subTrackId: t.id,
// subTrackId: t.id,
subTrackId: 999,
challenges: t.challenges,
wins: t.wins,
mostRecentSubmission: readDate(t.mostRecentSubmission),
Expand Down Expand Up @@ -156,7 +157,8 @@ function buildDesignStatsData (jsonData) {
}
const itemData = jsonData.subTracks
const items = _.map(itemData, t => ({
subTrackId: t.id,
// subTrackId: t.id,
subTrackId: 999,
mostRecentSubmission: readDate(t.mostRecentSubmission),
mostRecentEventDate: readDate(t.mostRecentEventDate),
..._.pick(t, designStatsItemFields),
Expand Down Expand Up @@ -407,6 +409,8 @@ async function importStatsHistory () {
_.forEach(srmHistory, t => {
dataScienceItems.push({
subTrack: 'SRM',
// subTrackId:t.id,
subTrackId: 999,
createdBy,
..._.pick(t, ['challengeId', 'challengeName', 'rating', 'placement', 'percentile']),
date: new Date(t.date)
Expand All @@ -417,6 +421,8 @@ async function importStatsHistory () {
_.forEach(marathonHistory, t => {
dataScienceItems.push({
subTrack: 'MARATHON_MATCH',
// subTrackId:t.id,
subTrackId: 999,
createdBy,
..._.pick(t, ['challengeId', 'challengeName', 'rating', 'placement', 'percentile']),
date: new Date(t.date)
Expand Down Expand Up @@ -471,6 +477,7 @@ async function mockPrivateStatsHistory () {
placement: 1,
percentile: 100,
subTrack: 'SRM',
subTrackId: 999,
createdBy
}, {
challengeId: 99997,
Expand All @@ -480,6 +487,7 @@ async function mockPrivateStatsHistory () {
placement: 1,
percentile: 100,
subTrack: 'MARATHON_MATCH',
subTrackId: 999,
createdBy
}]
}
Expand Down
Loading