-
Notifications
You must be signed in to change notification settings - Fork 9
Frontend compatibilty fixes #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements frontend compatibility changes by modifying the challenge fetching approach from loading all challenges at once to first fetching challenge metadata and then individual challenges on demand. The API now provides different response structures for regular users (ChallengeResp
) versus admins (AdminChallengeResp
).
- Updates TOML configuration field names from snake_case to camelCase (e.g.,
dynamic_flag
→dynamicFlag
) - Adds new database functions for metadata-only queries and challenge solve statistics
- Implements time-series data aggregation for leaderboard graphs with configurable time buckets
- Refactors API endpoints to return structured challenge metadata vs full challenge details
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
File | Description |
---|---|
templates/templates.go | Updates template field names from snake_case to camelCase |
core/utils/cleanup.go | Adds comment about leaderboard cache persistence |
core/manager/utils.go | Adds difficulty field handling with default value |
core/database/user.go | Adds function to query unique challenge tags |
core/database/tag.go | Adds metadata-only query function for related challenges |
core/database/challenges.go | Adds multiple new functions for metadata queries, solve statistics, and time-series data |
core/constants.go | Adds leaderboard graph size constant |
core/config/challenge.go | Updates TOML field names to camelCase and adds difficulty field |
api/router.go | Updates route handlers and adds new endpoints |
api/response.go | Restructures response types for challenge metadata and details |
api/info.go | Major refactor of challenge info handlers to use new metadata approach |
api/admin.go | Updates cache invalidation logic |
_examples/ | Updates example TOML files to use new camelCase field names |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sukhman-sukh , I have added some comments. Please go through them
|
||
users, err := database.GetRelatedUsers(&challenge) | ||
if len(challenges) > 0 && challenges[0].Status != "Undeployed" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using raw strings, please prefer enum types
@@ -417,84 +393,34 @@ func challengesInfoHandler(c *gin.Context) { | |||
} | |||
|
|||
for index, challenge := range challenges { | |||
users, err := database.GetRelatedUsers(&challenge) | |||
if challenge.Status == "Undeployed" && user.Role == core.USER_ROLES["contestant"] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well
|
||
func getLeaderboardGraphHandler(c *gin.Context) { | ||
var topUsers []uint | ||
// TODO: Add a check for leaderboard stale to prevent stale graphs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain what's going on here.
if !graphCacheStale || isLeaderboardFrozen { | ||
c.JSON(http.StatusOK, graphCache) | ||
} else { | ||
// TODO: Add a fallback for frozen leaderboard as graphcache is in memory and not persistent. SO, might get lost if server got down in between. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make an issue for this if not already done
Backend changes for frontend compatibility.
In this PR, Major update is changing the challenge fetching from fetching all the challenges at once to first fetching
ChallengeMetdata
and then fetch individual challenges one by one as needed. The client getsChallengeResp
whereas the admin getsAdminChallengeResp
.