Skip to content

Fix track names dot Error#322

Open
balebbae wants to merge 2 commits intohackutd:masterfrom
balebbae:fix-dot-track-names
Open

Fix track names dot Error#322
balebbae wants to merge 2 commits intohackutd:masterfrom
balebbae:fix-dot-track-names

Conversation

@balebbae
Copy link
Contributor

Description

Track names that had dots caused 500. Read issue details.
For the fix I encoded the track name URLs on the FE for HTTP routing. And added a read modify write pattern for UpdateTrackQRCode(), UpdateProjectTrackStars(), UpdateAfterSeen().

Eg. UpdateTrackQRCode:

  1. Read full options doc.
  2. update TrackQRCodes map
  3. sets entire map fields back

Fixes #320

Type of Change

Delete options that do not apply:

  • Bug fix (change which fixes an issue)

Is this a breaking change?

  • Yes
  • No

@vercel
Copy link

vercel bot commented Feb 23, 2026

@balebbae is attempting to deploy a commit to the Michael Zhao's projects Team on Vercel.

A member of the Team first needs to authorize it.

@balebbae balebbae requested a review from veermshah February 23, 2026 02:37
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jury Ready Ready Preview, Comment Feb 24, 2026 4:45am

Comment on lines +185 to +197
project, findErr := FindProject(db, ctx, &seenProject.ProjectId)
if findErr != nil {
return errors.New("error finding project: " + findErr.Error())
}
if project.TrackSeen == nil {
project.TrackSeen = make(map[string]int64)
}
project.TrackSeen[judge.Track] += 1
_, err = db.Collection("projects").UpdateOne(
ctx,
gin.H{"_id": seenProject.ProjectId},
gin.H{"$set": gin.H{"track_seen": project.TrackSeen, "last_activity": util.Now()}},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Functionality is fine, but I'd suggest extracting this to a helper function for readability.

Comment on lines +177 to +182
options, err := GetOptions(db, ctx)
if err != nil {
return err
}
options.TrackQRCodes[track] = qrCode
_, err = db.Collection("options").UpdateOne(ctx, gin.H{}, gin.H{"$set": gin.H{"track_qr_codes": options.TrackQRCodes}})
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap this in withTransaction

Comment on lines 321 to 339
func UpdateProjectTrackStars(db *mongo.Database, ctx context.Context, projId primitive.ObjectID, track string, increment bool) error {
change := -1
if increment {
change = 1
project, err := FindProject(db, ctx, &projId)
if err != nil {
return err
}
track_str := "track_stars." + track

_, err := db.Collection("projects").UpdateOne(ctx, gin.H{"_id": projId}, gin.H{"$inc": gin.H{track_str: change}})
if project == nil {
return errors.New("project not found")
}
change := int64(1)
if !increment {
change = -1
}
if project.TrackStars == nil {
project.TrackStars = make(map[string]int64)
}
project.TrackStars[track] += change
_, err = db.Collection("projects").UpdateOne(ctx, gin.H{"_id": projId}, gin.H{"$set": gin.H{"track_stars": project.TrackStars}})
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So funny story since we store stars on judges, this isn't actually used and the project.TrackStars field only gets populated in ListProjects in server/router/project.go. Although not related to this issue, can you just remove this function?

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.

Status 500 Error: generate QR Code for "." in Track Name

2 participants