Skip to content

Added new feature: Contest Percentile graph, showing plots for each t…#8

Open
rahulharpal1603 wants to merge 1 commit intoApoorvaRajBhadani:mainfrom
rahulharpal1603:feature-ContestPercentiles
Open

Added new feature: Contest Percentile graph, showing plots for each t…#8
rahulharpal1603 wants to merge 1 commit intoApoorvaRajBhadani:mainfrom
rahulharpal1603:feature-ContestPercentiles

Conversation

@rahulharpal1603
Copy link
Copy Markdown

Pull Request Description: Contest Percentiles Feature

image

image

Demo Video for Google Chrome and Firefox: Link

(Video is Unlisted on YouTube)

This pull request introduces a feature to display contest percentiles for Codeforces users. The percentile data for each division (D1, D1+2, D2, ED2, D3, D4) is retrieved from the Codeforces API and supplemented with participant count data from a JSON file hosted on this repository.

Percentile of a user is simply calculated using this formula: 100 - ((rankInContest/totalParticipantsInContest) *100)

We have plotted separate line for each division because the user can compare the his/her performance across divisions, higher the percentile, better the performance. The tooltips you see in the video when we hover over a data point is coded so that it displays different time in accordance with different time zones i.e if a user lives in India (Time Zone: GMT+5:30), he will be shown a different time than some user living in Moscow (Time Zone: GMT+3)

The resulting percentiles are plotted on a line chart with time (contest start date) on the x-axis and percentile on the y-axis. Initially, only the division with the most contests is visible, while other divisions can be toggled for viewing.

Summary of Changes:

  • Fetched contest data from the Codeforces API and a participant count JSON file.
  • Processed data to calculate user percentiles.
  • Displayed percentiles in a multi-line chart using Chart.js, categorized by contest division.
  • Initially, only one division is shown based on the number of contests, with the option to toggle others.
  • Added interactive features, including tooltips and the ability to hide/show division data on the chart.

Why a separate file for Participant Count?

It is not possible to get the number of participants in a contest from the CF API. Because of this, we have to use the CLIST API to retrieve data for participant count. Also, CLIST does not allow API requests without an API Key, so I have set up our own JSON File, which is updated with contest data every hour (if any updates are there). We can easily access this JSON file in the extension without any API Key.

The filtered_data.json is present in this repository, which stores Codeforces contest data, including participant counts, contest names, divisions, and start times. A Python script automatically updates this file every hour by:

  1. Fetching New Contests: It retrieves data from the CLIST API to check for new contests.
  2. Updating Data: The script compares the fetched contests with existing entries in the JSON file and adds any new contests along with their details.
  3. Scheduled Workflow: A GitHub Actions workflow runs the script, committing changes to the repository. The workflow securely handles API keys and tokens.

This ensures the contest data is always up to date for percentile calculations.

NOTE: The huge number of insertions (5800+) is due to the addition of a library called Moment.js to plot the graph where the x-axis is time.

@rahulharpal1603
Copy link
Copy Markdown
Author

@ApoorvaRajBhadani Please review the above Pull Request.

@rahulharpal1603
Copy link
Copy Markdown
Author

@ApoorvaRajBhadani Is this PR ok?

@ApoorvaRajBhadani
Copy link
Copy Markdown
Owner

Have not yet checked the code completely. Will set up some time with you.

@rahulharpal1603
Copy link
Copy Markdown
Author

Have not yet checked the code completely. Will set up some time with you.

Okay 👍

@rahulharpal1603
Copy link
Copy Markdown
Author

@ApoorvaRajBhadani My winter break is going on, so I will always be available to discuss it whenever you are available.

@rahulharpal1603
Copy link
Copy Markdown
Author

@ApoorvaRajBhadani sir please review this😅

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