Skip to content

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

Merged
merged 3 commits into from
Aug 16, 2025
Merged

Conversation

sukhman-sukh
Copy link
Contributor

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 gets ChallengeResp whereas the admin gets AdminChallengeResp.

@sukhman-sukh sukhman-sukh requested a review from Copilot August 14, 2025 03:52
@sukhman-sukh sukhman-sukh changed the base branch from master to bl4ze/dev August 14, 2025 03:52
Copilot

This comment was marked as outdated.

@sukhman-sukh sukhman-sukh requested a review from Copilot August 15, 2025 20:46
Copilot

This comment was marked as outdated.

@sukhman-sukh sukhman-sukh requested a review from Copilot August 15, 2025 23:43
Copy link

@Copilot Copilot AI left a 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_flagdynamicFlag)
  • 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.

@sukhman-sukh sukhman-sukh merged commit 5b6da93 into bl4ze/dev Aug 16, 2025
Copy link
Contributor

@v1bh475u v1bh475u left a 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" {
Copy link
Contributor

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"] {
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants