Backend state consolidation and db function refactoring#264
Merged
MichaelZhao21 merged 5 commits intomasterfrom Apr 23, 2025
Merged
Backend state consolidation and db function refactoring#264MichaelZhao21 merged 5 commits intomasterfrom
MichaelZhao21 merged 5 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the backend by consolidating state into a unified object that’s passed into routes and refactors database functions to improve transaction and context handling. Key changes include:
- Introducing a State struct to encapsulate db, logger, clock, comparisons, and limiter components.
- Updating database function calls and transaction wrappers to use a consistent context.
- Adjusting error handling and logging messages to reflect the new structure.
Reviewed Changes
Copilot reviewed 16 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| server/router/state.go | Introduces the new State object for shared dependencies. |
| server/router/project.go | Updates route handlers to use GetState(ctx) and transaction calls. |
| server/router/init.go | Consolidates context variables by creating and attaching State. |
| server/router/admin.go | Refactors admin routes to use the unified State for logging/db access. |
| Other server/database and server/judging files | Refactors various database functions to accept context and transactions. |
Files not reviewed (3)
- Dockerfile: Language not supported
- dev.Dockerfile: Language not supported
- server/go.mod: Language not supported
Comments suppressed due to low confidence (2)
server/router/project.go:56
- The error message refers to 'judges' even though the operation inserts projects. Please update the message to 'error inserting projects into database'.
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "error inserting judges into database: " + err.Error()})
server/judging/judging_flow.go:140
- [nitpick] The function name 'FindAvaliableItems' contains a spelling error. Consider renaming it to 'FindAvailableItems' for clarity.
func FindAvaliableItems(db *mongo.Database, ctx context.Context, judge *models.Judge, comps *Comparisons) ([]*models.Project, error) {
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
Fixes #155
Fixes #97
Type of Change
Delete options that do not apply:
Is this a breaking change?