Skip to content

Commit

Permalink
v1.0 (#16)
Browse files Browse the repository at this point in the history
* v1.0 (#4)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* v1.0: Added Procfile (#7)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Fixing ENV files (#8)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Delete .env.dev

* Delete .env.prod

* Delete .env.staging

* Fixing Procfile (#9)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Fixed Procfile bug

* v1.0 (#10)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Fixed Procfile bug

* Procfile changes

* Specified node version in package.json

* Changed Procfile starting command

* Configured post install and start commands for Heroku

* Fixed CORS bug

* Fixed login response error code

* Delete Procfile

* v1.0 (#12)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Fixed Procfile bug

* Procfile changes

* Specified node version in package.json

* Changed Procfile starting command

* Configured post install and start commands for Heroku

* Fixed CORS bug

* Fixed login response error code

* Removing unused Procfile

* v1.0: Bug Fixes (#14)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Fixed Procfile bug

* Procfile changes

* Specified node version in package.json

* Changed Procfile starting command

* Configured post install and start commands for Heroku

* Fixed CORS bug

* Fixed login response error code

* Removing unused Procfile

* Fixed Analysis Service Bugs

- App crashes when submissions length is zero in solving rate
- Average Rank and Rating change in set to zero when ratingChanges length is zero

* Too many Requests to CF API bug fix

- Configured axios retries

* Fixed CF Contests Show All Bug

- Sorted the Contests according to ID

* v1.0 (#15)

* Implemented Follow Feature

- Added /follow and /unfollow endpoints
- Added following to the User Class, DTO, and Schema
- Added Typings for the User object in the authenticated Request

* Implemented User Search

- Added GET users/search? Endpoint
- Added name to the index of the User Schema
- Added searchUsers to the UserRepository
- Change follow, unfollow Enpoints to POST Requests

* Implemented CFContests Endpoint

- Added CFContest Class / DTO / Schema
- Added createContest input validation
- Added CFContests Controller
- Added CREATE / READ / DELETE endpoints

* Implemented Sheets Analysis

- Added contest standings and contest status to CF Service
- Added Expiry time to user auth tokens
- Added problem index to Codeforces.Problem interface

* Implemented user confirmation for mentors

- Added isConfirmed member to User Class / DTO / Schema
- Added confirm endpoint in accounts controller
- Added Admin Role and changed Admin endpoints authorization

* Added GET unconfirmed users backend endpoint

- Added PUT to allowed method in server
- Fixed cf contest validation schema bug

* Prepared the App for deployment

- Added different ENV files for different Environments
- Added config file to load the appropriate ENV file

* Fixed env files loading bug

* Fixed env loading bug

- production env file typo in envConfig
- loading dev env file in tests

* Added Procfile

* Removed env files

* Fixed Procfile bug

* Procfile changes

* Specified node version in package.json

* Changed Procfile starting command

* Configured post install and start commands for Heroku

* Fixed CORS bug

* Fixed login response error code

* Removing unused Procfile

* Fixed Analysis Service Bugs

- App crashes when submissions length is zero in solving rate
- Average Rank and Rating change in set to zero when ratingChanges length is zero

* Too many Requests to CF API bug fix

- Configured axios retries

* Fixed CF Contests Show All Bug

- Sorted the Contests according to ID

* Codeforces Too many requests bug fix

- Changed the contest analysis to a complete synchronous code to avoid multiple requests at the same time
- changed retries count to 3

* Changed back contests count in analysis to 5

* Removed Admin Accounts and Self from appearing in search results

* Allowed . and - in handles registration

* Solved Problems and Tags are sorted lexicographically
  • Loading branch information
khaled-hamam authored Oct 26, 2018
1 parent 5b85808 commit 5fa225c
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 31 deletions.
11 changes: 9 additions & 2 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"axios-retry": "^3.1.1",
"bcrypt": "^3.0.0",
"body-parser": "^1.18.3",
"compression": "^1.7.3",
Expand Down
11 changes: 11 additions & 0 deletions src/config/axiosConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import axios from 'axios';
import axiosRetry from 'axios-retry';

// Setting up retry in case of 429 response (Too many requests)
axiosRetry(axios, {
retries: 3,
retryCondition: error => {
return error.response ? error.response.status === 429 : false;
},
retryDelay: count => count * 1000
});
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import './axiosConfig';
import './envConfig';
2 changes: 1 addition & 1 deletion src/controllers/CFContestsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class CFContestsController implements IController {
*/
private async getContests(req: Request, res: Response) {
const contests = await this.cotenstsRepository.findAll();
res.json(contests);
res.json(contests.sort((a, b) => +b._id - +a._id));
}

/**
Expand Down
24 changes: 13 additions & 11 deletions src/controllers/UserSearchController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ export default class UserSearchController implements IController {
throw new ApiError();
}

const searchResultFiltered = searchResult.map(user => {
const filteredUser: any = _.pick(user, [
'handle',
'name',
'email',
'role',
'onlineJudgesHandles'
]);
filteredUser.isFollowed = authenticatedUser.following.indexOf(user._id as string) !== -1;
return filteredUser;
});
const searchResultFiltered = searchResult
.map(user => {
const filteredUser: any = _.pick(user, [
'handle',
'name',
'email',
'role',
'onlineJudgesHandles'
]);
filteredUser.isFollowed = authenticatedUser.following.indexOf(user._id as string) !== -1;
return filteredUser;
})
.filter(user => user.role !== Role.Admin && user.name !== req.user.name);

res.send(searchResultFiltered);
}
Expand Down
36 changes: 20 additions & 16 deletions src/services/AnalysisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CodeforcesService } from './onlinejudges/CodeforcesService';
import { Verdict } from './onlinejudges/Verdict.enum';
import { secondsToDuration } from '../utils/secondsToDuration';
import { ICFContestRepository, CFContestRepository } from '../repositories/CFContestRepository';
import { sortObjectKeys } from '../utils/sortObjectKeys';

export default class AnalysisService {
private cfContestsRepository: ICFContestRepository = new CFContestRepository();
Expand Down Expand Up @@ -60,7 +61,7 @@ export default class AnalysisService {
}
}

return tagsFrequency;
return sortObjectKeys(tagsFrequency);
}

public analyseSolvingRate(submissions: Codeforces.Submission[]) {
Expand Down Expand Up @@ -117,21 +118,24 @@ export default class AnalysisService {
const contests = (await this.cfContestsRepository.findAll())
.sort((a, b) => +b._id - +a._id)
.slice(0, 5);
return await Promise.all(
contests.map(async contest => {
// Fetching contest Standings, Submissions
const standings = await this.cfService.getContestStandings(contest._id, codeforcesHandle);
let submissions = await this.cfService.getContestSubmissions(contest._id, codeforcesHandle);
submissions = submissions.filter(submission => submission.verdict === Verdict.OK);
submissions = _.uniqBy(submissions, 'problem.name');

return {
contestName: contest.name,
rank: standings.rows[0] ? standings.rows[0].rank : 0,
solvedCount: submissions.length,
solvedProblems: submissions.map(submission => submission.problem.index)
};
})
);
const contestsAnalysis: any[] = [];
for (const contest of contests) {
const standings = await this.cfService.getContestStandings(contest._id, codeforcesHandle);
let submissions = await this.cfService.getContestSubmissions(contest._id, codeforcesHandle);
submissions = submissions.filter(submission => submission.verdict === Verdict.OK);
submissions = _.uniqBy(submissions, 'problem.name');
contestsAnalysis.push({
contestName: contest.name,
rank: standings
? standings.rows[0]
? standings.rows[0].rank
: 0
: 'Failed to get the rank',
solvedCount: submissions.length,
solvedProblems: submissions.map(submission => submission.problem.index).sort()
});
}
return contestsAnalysis;
}
}
16 changes: 15 additions & 1 deletion src/utils/validation/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import { toErrorBody } from './toErrorBody';

export function validateRegisterInput(input: any) {
const registerInputSchema = {
handle: joi.string().token(),
handle: joi
.string()
.regex(/^[A-Za-z0-9._-]+$/)
.error(err => {
if (err[0].type === 'string.regex.base') {
return {
message: '"handle" must only contain alpha-numeric, _, -, and . characters',
...err
};
} else {
return err;
}
})
.min(3)
.max(20),
name: joi
.string()
.min(3)
Expand Down

0 comments on commit 5fa225c

Please sign in to comment.