Skip to content

Add flag to db #410

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

Open
wants to merge 2 commits into
base: bl4ze/dev
Choose a base branch
from
Open

Add flag to db #410

wants to merge 2 commits into from

Conversation

sukhman-sukh
Copy link
Contributor

Add all the flags submitted by the user to the userChallenges DB.

@sukhman-sukh sukhman-sukh changed the base branch from master to bl4ze/dev March 14, 2025 00:51
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 updates flag submission handling by recording all submitted flags in the userChallenges DB and modifies responses accordingly.

  • Adds detailed error checking after updating user challenge tries.
  • Saves both correct and incorrect flag submissions in the database.
  • Enhances API responses to include the submitted flag field.

Reviewed Changes

Copilot reviewed 4 out of 9 changed files in this pull request and generated 1 comment.

File Description
api/submit.go Implements flag saving in both correct and incorrect cases and adds extra error checking.
api/response.go Adds a new JSON field for the flag in flag submission responses.
api/info.go Includes the flag in the submission information sent to clients.
Files not reviewed (5)
  • api/docs/swagger.json: Language not supported
  • api/docs/swagger.yaml: Language not supported
  • api/docs/swagger/swagger.json: Language not supported
  • api/docs/swagger/swagger.yaml: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

api/submit.go:229

  • [nitpick] Consider renaming 'UserChallengesEntry' to 'userChallengesEntry' for consistency with Go naming conventions.
UserChallengesEntry := database.UserChallenges{

@@ -215,29 +226,27 @@ func submitFlagHandler(c *gin.Context) {
}
} else {
if challenge.Flag != flag {
UserChallengesEntry := database.UserChallenges{
CreatedAt: time.Time{},
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'CreatedAt' field is initialized with time.Time{}, which results in a zero timestamp; consider using time.Now() to record the actual submission time.

Suggested change
CreatedAt: time.Time{},
CreatedAt: time.Now(),

Copilot uses AI. Check for mistakes.

@sukhman-sukh
Copy link
Contributor Author

Anything to fix here ?

@v1bh475u
Copy link
Contributor

Yes. Please make the change suggested by copilot.

@sukhman-sukh
Copy link
Contributor Author

@v1bh475u, is there anything else to add other than copilot fixes?

@v1bh475u
Copy link
Contributor

v1bh475u commented Jun 5, 2025

Nope. All good to go!

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