Skip to content
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

Issue 16 part2 #18

Merged
merged 3 commits into from
Nov 4, 2017
Merged

Issue 16 part2 #18

merged 3 commits into from
Nov 4, 2017

Conversation

d-s-x
Copy link
Contributor

@d-s-x d-s-x commented Nov 3, 2017

This restores points calculation for optimization puzzles (code golf).

The issue is that in previous pull-request only rankings for current user were returned from cg server and as result the user always got 200 points.

This PR implements puzzle stats downloading for all languages that user solved the puzzle with.

// *****************************

function getStats(resource, parameters) {
return new Promise(function(resolve, reject) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to introduce another dependency so I simply wrapped existing request into new promise.
Promise required for async downloading of stats for all languages that the user solved the puzzle with.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cgstats run in a nodejs 8+. Don't worry for Promise :p

@@ -126,37 +126,74 @@ app.get('/search*', function(req, res) {
});
});
} else if (optimizations.indexOf(game) != -1) {
getStats('LeaderboardsRemoteService/getFilteredPuzzleLeaderboard',
[game, , , {"active" : true, "column" : "keyword", "filter" : player}])
.then(function (response) {
Copy link
Contributor Author

@d-s-x d-s-x Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this response contains rankings only for requested keyword, like

{ users: 
   [ { pseudo: 'd-s-x',
       rank: 63,
       globalRank: 63,
       localRank: 63,
       score: 100,
       testSessionHandle: '48277672d595cdc4b03e02abca6bda19f64a5cb',
       programmingLanguage: 'Bash',
       inProgress: false,
       criteriaScore: 38,
       company: '',
       codingamer: [Object] },
     { pseudo: 'd-s-x',
       rank: 64,
       globalRank: 64,
       localRank: 64,
       score: 100,
       testSessionHandle: '48277672d595cdc4b03e02abca6bda19f64a5cb',
       programmingLanguage: 'Perl',
       inProgress: false,
       criteriaScore: 38,
       company: '',
       codingamer: [Object] },
     { pseudo: 'd-s-x',
       rank: 221,
       globalRank: 221,
       localRank: 221,
       score: 100,
       testSessionHandle: '48277672d595cdc4b03e02abca6bda19f64a5cb',
       programmingLanguage: 'Ruby',
       inProgress: false,
       criteriaScore: 50,
       company: '',
       codingamer: [Object] },
...

so we have to download more stats but with language filter instead

@dreignier dreignier merged commit 64cf0d8 into dreignier:master Nov 4, 2017
@d-s-x d-s-x deleted the issue-16 branch November 4, 2017 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants