Open
Conversation
|
@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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
MichaelZhao21
requested changes
Feb 26, 2026
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()}}, | ||
| ) |
Contributor
There was a problem hiding this comment.
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}}) |
Contributor
There was a problem hiding this comment.
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 | ||
| } |
Contributor
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Fixes #320
Type of Change
Delete options that do not apply:
Is this a breaking change?