Bug Description
The LeetCode data fetching relies on an unmaintained third-party API (alfa-leetcode-api.onrender.com) that is prone to downtime on Render's free tier.
Affected File
api/leaderboard/views.py:463
Problem
def get_leetcode_data(self, username):
url = f"https://alfa-leetcode-api.onrender.com/userProfile/{username}"
response = requests.get(url)
This API:
- Is hosted on Render's free tier (sleeps after 15 min of inactivity)
- Is not officially maintained by LeetCode
- Could be taken down at any time
- Introduces a single point of failure for ALL LeetCode data
If this API is down, no LeetCode user data can be refreshed, and the entire LeetCode leaderboard section becomes stale.
Proposed Fix
The codebase already has commented-out code in api/leaderboard/api/views.py (lines 374-418) that queries LeetCode's official GraphQL endpoint at leetcode.com/graphql directly. This should be the primary data source.
LeetCode's GraphQL schema supports:
query { userContestRankingHistory(username: "...") { attended ranking contest { title startTime } } }
query { matchedUser(username: "...") { submitStats: submitStatsGlobal { acSubmissionNum { difficulty count submissions } } profile { reputation ranking reputation } } }
Implement direct calls to https://leetcode.com/graphql with proper query parameters. The existing commented code in get_data_from_url() and ContestRankingsAPIView() shows the pattern already works.
Severity
MEDIUM — Complete data pipeline failure when the third-party API is unavailable.
Bug Description
The LeetCode data fetching relies on an unmaintained third-party API (
alfa-leetcode-api.onrender.com) that is prone to downtime on Render's free tier.Affected File
api/leaderboard/views.py:463Problem
This API:
If this API is down, no LeetCode user data can be refreshed, and the entire LeetCode leaderboard section becomes stale.
Proposed Fix
The codebase already has commented-out code in
api/leaderboard/api/views.py(lines 374-418) that queries LeetCode's official GraphQL endpoint atleetcode.com/graphqldirectly. This should be the primary data source.LeetCode's GraphQL schema supports:
Implement direct calls to
https://leetcode.com/graphqlwith proper query parameters. The existing commented code inget_data_from_url()andContestRankingsAPIView()shows the pattern already works.Severity
MEDIUM — Complete data pipeline failure when the third-party API is unavailable.