[FOSSOVERFLOW-26] feat: add functionality to friends button (#160)
Title
[FOSSOVERFLOW-26] feat: add functionality to friends button (#160)
Description
This PR implements the Friends button workflow end-to-end by introducing a dedicated Friends management page and wiring all required friend actions across leaderboards.
It is needed to resolve issue #160, where users should be able to view friended users with ranking/info and unfriend from one place.
Related Issue(s)
- Fixes #160
- Related to #182
Changes
- Added a new
/friendspage to show friends across Codeforces, CodeChef, LeetCode, GitHub, and OpenLake. - Wired sidebar
Friendsnavigation item to route to/friends. - Added platform-wise friend sections with ranking position + key stats + profile links.
- Added remove/unfriend action directly from the Friends page for each platform.
- Completed Codeforces friends API integration (
/codeforcesFL,/codeforcesFA,/codeforcesFD) and removed localStorage-only fallback logic.
Screenshots of relevant screens
None (will be added in follow-up update).
Type of Change
- [ ] Bug fix
- [x] Feature
- [ ] Breaking change
- [ ] Docs
- [x] Refactor
Checklist
- [x] Code follows project style
- [x] Tested locally
- [ ] Docs updated (if needed)
- [x] No new warnings
Notes
- Frontend lint passes (
npm run lintinapp/). - Existing project-wide warnings were not increased by this PR.
- If maintainers prefer, I can split Codeforces backend-integration changes into a separate PR, but they are directly relevant to #160 completion.
Summary by CodeRabbit
-
New Features
- Dedicated, protected Friends page showing friends across Codeforces, CodeChef, LeetCode, GitHub, and OpenLake with a Refresh button and per-platform sections.
- Ability to remove friends per platform; add flow now prevents duplicates and confirms success before updating lists.
- Navigation updated to link to the Friends page; friends data is supplied to the Friends page.
-
Bug Fixes
- Friends data clears on logout and requires authentication to view; friend lists load from the backend and show error banner on failures.
-
UI
- Friends leaderboard now shows "Sorted by rating" label.
[!WARNING]
Rate limit exceeded
@VarshiniGuntihas exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 15 seconds before requesting another review.⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID:
48e165f0-11eb-4d9e-9a73-cb3bd1aaa8a7📥 Commits
Reviewing files that changed from the base of the PR and between 1561a56cefc3daf8f7d3ee5d11c3ae71da015105 and 8c7f36b8c59cf729eb28572af3fb70d09259348f.
📒 Files selected for processing (2)
app/src/components/CodeforcesTable.jsxapp/src/components/FriendsPage.jsx
Walkthrough
Added a protected /friends route and a new FriendsPage component that fetches, displays, and lets the user remove friends across five platforms using backend endpoints and Bearer token authentication; Codeforces table friend flows were migrated to backend calls and safe JSON parsing.
Changes
| Cohort / File(s) | Summary |
|---|---|
Routing & Navigation app/src/App.jsx, app/src/Navbar.jsx |
Added protected /friends route rendering FriendsPage (passes platform user lists); updated Navbar Friends link to /friends. |
Codeforces friends integration app/src/components/CodeforcesTable.jsx |
Replaced localStorage friends logic with authenticated backend GET/POST endpoints; added readJsonIfAvailable() for content-type guarded parsing; added server-backed add/remove flows and logout handling. |
Friends UI & orchestration app/src/components/FriendsPage.jsx |
New component implementing PLATFORM_CONFIG, concurrent platform fetches (Promise.allSettled), loading/error state, per-platform friend tables, rank/metric computations, and friend-removal POST calls with local state updates. |
Sequence Diagram
sequenceDiagram
participant User as User (Browser)
participant App as FriendsPage Component
participant Auth as Auth System
participant Backend as Backend API
participant UI as Friend Display
User->>App: Navigate to /friends
App->>Auth: request access token
Auth-->>App: return access token
rect rgba(100,150,200,0.5)
Note over App,Backend: Concurrent fetches for each platform
App->>Backend: GET /codeforcesFL/ + Bearer token
App->>Backend: GET /codechefFL/ + Bearer token
App->>Backend: GET /leetcodeFL/ + Bearer token
App->>Backend: GET /githubFL/ + Bearer token
App->>Backend: GET /openlakeFL/ + Bearer token
end
Backend-->>App: responses (JSON or non-JSON)
App->>App: readJsonIfAvailable() -> validate arrays
App->>App: merge/sort -> build friendsByPlatform
App->>UI: render platform friend tables
User->>UI: click "Remove"
UI->>Backend: POST /<platform>FD/ { friendName } + Bearer token
Backend-->>UI: success
UI->>App: update local friendsByPlatform (filter out)
App->>User: re-render updated tables
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
- OpenLake/Leaderboard-Pro#191: Implements backend-backed friend fetch/add/remove and auth-guarded flows; closely related to the move from localStorage to server endpoints and safe JSON parsing.
Poem
🐰 I hopped into code with a curious twitch,
Five leaderboards shining, each in a niche,
Tokens in paw, I fetch and I show,
Ranks in a row where friendships grow,
Click unfriend—poof!—and onward I twitch. 🎉
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The PR title clearly describes the main feature: adding functionality to the friends button/workflow, which is the primary objective of the changeset. |
| Description check | ✅ Passed | The PR description covers all required template sections: purpose, related issues, key changes, type of change, and a completed checklist with notes about testing and code quality. |
| Linked Issues check | ✅ Passed | The PR successfully implements issue #160's core requirements: a unified friends page showing users across platforms, displaying rankings/info, and enabling unfriend actions. |
| Out of Scope Changes check | ✅ Passed | All changes directly support the friends button functionality: new FriendsPage component, backend API integration for friend management, routing updates, and Codeforces leaderboard modifications—all within scope of issue #160. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRASome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the feat/160-friends-button-functionality branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23383168017/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:fullstack/dict/fullstack.txt | 419 | 42 | 8 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRASome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the feat/160-friends-button-functionality branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23383260546/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:fullstack/dict/fullstack.txt | 419 | 42 | 8 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRASome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the feat/160-friends-button-functionality branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23383368977/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:fullstack/dict/fullstack.txt | 419 | 42 | 8 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRASome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the feat/160-friends-button-functionality branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23383474790/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:fullstack/dict/fullstack.txt | 419 | 42 | 8 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).