baoliay2008 / lccn_predictor

LeetCode Contest Rating Prediction
https://lccn.lbao.site
MIT License
570 stars 22 forks source link

Country Ranking #4

Open recepkucek opened 1 year ago

recepkucek commented 1 year ago

Could you please add country ranking ?

baoliay2008 commented 1 year ago

Hi, @recepkucek If I understand correctly, is country ranking means that someone's ranking within a country?

For example, the current global ranking is like

username country ranking
Alice Austria 1
Bob Canada 2
Clare Austria 3
Dolores Austria 4
Eve Canada 5

And country ranking is something like this:

Please correct me if I am wrong.

recepkucek commented 1 year ago

I think, country filter for each contest might be enough. For example, when opened contest detail page there is a search for username so you can add another filter for country. If country selected only users related to that country will be listed(for selected contest). Also I think global country based ranking is needed because in the following link there is no country filter. https://leetcode.com/contest/globalranking/ These two features would be very useful.

amitpant14 commented 1 year ago

Hi @baoliay2008 Can you please assign this to me if this is not taken up yet?

amitpant14 commented 1 year ago

@baoliay2008 thanks for assigning. @recepkucek Can you explain the second feature? I only understand one that is to add a country filter which would display a rank list only for the users of selected country. I assume it would also allow search for a particular user name under the selected country filter.

recepkucek commented 1 year ago

@baoliay2008 thanks for assigning. @recepkucek Can you explain the second feature? I only understand one that is to add a country filter which would display a rank list only for the users of selected country. I assume it would also allow search for a particular user name under the selected country filter.

Sure. Yes you are right and this should be in separate page. The following link shows it exactly, https://leetcode-country-ranking.onrender.com/country/GB .

To clarify 1 - In each contest page, filtering users by country and sorting by their ranking in the contest. 2 - For all contests, listing users by country and sorting by their global ranking.

So users can compare themselves with other users in a country for each contest or all contests. If you need I can also send mock design of the features.

baoliay2008 commented 1 year ago

Implementing the first feature should be straightforward since all the data for a specific contest is stored in the database. It should be sufficient to update the API and front-end to support the new feature.


However, I believe that adding the second feature to this APP could be challenging because for now we only have cached information, primarily the ratings and attendance counts of users in recent contests. This limited data cannot be used to create a comprehensive global ranking. For instance:

  1. if Alice recently changed her LeetCode ID after participating in the last contest, we won't have her updated information
  2. if Bob participated in a contest a long time ago, we might not have his current information either.
  3. more additional cases that I am not currently recalling
amitpant14 commented 1 year ago

@baoliay2008 I will try to first run the app locally. Then will think about how to implement these features. I agree that the second feature would be challenging. I think we can prepare the global ranking of users from leetcode separately if that is possible somehow. Will look into this.

amitpant14 commented 1 year ago

@baoliay2008 What is the mongodb version used in the instance running live?

baoliay2008 commented 1 year ago

@baoliay2008 What is the mongodb version used in the instance running live?

@amitpant14 MongoDB server version: 5.0.8

amitpant14 commented 1 year ago

@baoliay2008 One question. The instructions for starting the backend mention first running the main.py file and then the uvicorn. I noticed that only the main.py file handles the schedulers and not the uvicorn. Do they both run simultaneously for the live deployment? One for schedulers and another for api endpoints?

baoliay2008 commented 1 year ago

@amitpant14 That's correct. I have implemented two distinct processes to allow for their execution on different machines, provided that they are connected to the same MongoDB database.

amitpant14 commented 1 year ago

@baoliay2008 Do you know how does leetcode saves the country information for a user? I could not see that detail in user profile update section on leetcode. Does that means country information is not set by user and cannot be edited?

baoliay2008 commented 1 year ago

@amitpant14 I guess updating Basic Info - Location should work?

amitpant14 commented 1 year ago

Yeah...but like for me this field is empty, still the country is picked up correctly. That's why I am a bit unsure. Another question, there is separate api call without pagination when username is searched, right? I am thinking of adding another field for country in the same form with username field. Noticed that complete list is fetched using another API call that has limit parameter. But for user, the call is without limit, which is fine as only one user with a specific username will be available. But if I add country field in the same form, limit parameter will need to be enabled for this call too. I was earlier thinking of using the same call as that of user/ endpoint for country too, but now I think separating them will be better.

amitpant14 commented 10 months ago

@baoliay2008 I have completed the first feature on my local branch. Below are the screenshots for reference: image image Please suggest if any changes should be made on the front-end side. I will refactor the code and then create a pull request.