sjsakib / cfviz

Visualizes user data from codeforces.com using the official API
http://cfviz.netlify.com
1.12k stars 70 forks source link

single.js: fixed solvedWithOneSub calculation #22

Closed archit-p closed 4 years ago

archit-p commented 4 years ago

Hello @sjsakib,

This pull request fixes a bug with the calculation of problems solved with one submission.

problems[problemId].attempts stores count of attemps before first submissions problems[problemId].solved stores count of right submissions solvedWithOneSub stores the count of how many problems were solved with one submission.

Currently we do if (problems[problemId].attempts == problems[problemId].solved) solvedWithOneSub++; however this will prove wrong in the case where the first submission was right, and then author went on to submit more right submissions.

Changing it to if (problems[problemId].attemps == 1) solvedWithOneSub++; seems to fix the issue in my case.

Please let me know if this approach could lead to issues elsewhere!

Signed-off-by: Archit Pandey architpandeynitk@gmail.com

sjsakib commented 4 years ago

I almost forgot how the entire thing works, but I think with you code, every first attempt will increase solvedWithOneSub, no matter if it was accepted or not. No?

archit-p commented 4 years ago

Right.

I did not account for the case where the problem is unsolved. Adding a check for problem[problemId].solved > 0 should do in my opinion.

Thoughts?

sjsakib commented 4 years ago

Yeah, update the code please

sjsakib commented 4 years ago

Thanks for your contribution 🙏

archit-p commented 4 years ago

My pleasure! Thanks for your efforts in maintaining such an amazing project!