Hello everyone! I am researching different forum platforms in order to build a community for Brazilian competitive programmers (CP) but it seems I have found it!
One feature I’d like to have on this forum is an integration with Codeforces - an online platform that hosts contests and discussions about CP. Within Codeforces, contestants have a rating that changes accordingly to the contestant’s performance in rated contests. I would like to give my users the ability to display their hard earned ratings on their forum’s profile.
The first thing this plugin I want to develop would have to do, then, is to allow the user to input their Codeforces’ handle and then somehow authenticate that the handle belongs to the forum user. In order to do that I’m thinking about using the Custom Wizard Plugin to ask their handle, then send a random string via Codeforces Talks API which the user would have to input back correctly and if everything is ok, store their handle on a custom user field. Does this seem okay? Would you do this differently?
Now, I know my [future] users, after all I’m a CPer myself! They would enjoy displaying their rating through their forum’s handle color. That is, if you have rating higher than 1400, you have a cyan colored handle, if it is higher than 1600, it’s blue colored, and so on.
My quick research on how to customize handle’s colors on Discourse brought me to the following solution. I should create a user group for each rating bracket, and then dynamically assign my users to the correct group. (Is there a better/easier way?)
So, when the user initially links their Codeforces account to their profile, I could retrieve their rating and assign to them the correct group (specialist, expert, candidate master, …, international grandmaster). However, the rating might soon change and I’d like to automatically update the user’s group when their rating change.
Now, I thought about some ways of accomplishing that and I’d like suggestions on which one to follow, and, if possible, some guiding on the Discourse-specifics:
- Have a regularly running Job that updates each users’ individual rating and group (a lot of external requests hitting Codeforces’ API)
- Have a regularly running Job that processes contests as they happen. Since ratings can only change during a contest, if the user’s rating are initially consistent, by processing rating changes as they happen I can update only the ratings that changed and maintain consistency with a single external API hit
- Have a custom rating and group resolver. So I’d have to store the last rating retrieval and upon the next
GET rating/groups, if the rating is stale, I’d hit Codeforces API and update the user’s rating/groups. This is my preferred solution because it seems easy and it will always be eventually consistent. However I am not so sure how I would go about implementing this or the consequences of dynamically removing and adding a group to a user. Or even if this is possible at all as a plugin.
Welp, I apologize for the Wall of Text! I’d love to have any kind of input about all of this. Thanks for attention.