From 0d6d24bbf60d453f7136d5c49a11e8e586a97e4a Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 19 Aug 2026 10:23:20 -0500 Subject: [PATCH 01/73] Add issue templates and pr template --- .../bug_report_issue_template.yml | 47 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 ++ .../feature_request_issue_template.yml | 38 +++++++++++++++ .../ISSUE_TEMPLATE/interal_issue_template.yml | 38 +++++++++++++++ .github/pull_request_template.md | 26 ++++++++++ 5 files changed, 154 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report_issue_template.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request_issue_template.yml create mode 100644 .github/ISSUE_TEMPLATE/interal_issue_template.yml create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml new file mode 100644 index 00000000..e276efff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml @@ -0,0 +1,47 @@ +name: 🪲 Bug Report +description: File a bug report +labels: ["Bug"] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this bug report! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + - type: textarea + id: description + attributes: + label: Description + description: What is the bug? + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps To Reproduce + description: Help us reproduce this bug. If helpful, you can include screenshots or logs! Be sure to wrap logs with ```` ```bash ```` before and ```` ``` ```` after. + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Describe the bug in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help. + validations: + required: false + - type: dropdown + id: version + attributes: + label: Version + description: Where did you find this bug? + options: + - api.utdnebula.com + - a local development branch + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: What environment were you using when you encountered this bug? + value: | + API Client: + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..b1ad4507 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: General Contact + url: https://about.utdnebula.com/about/contact + about: Get in touch here diff --git a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml new file mode 100644 index 00000000..a63db776 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml @@ -0,0 +1,38 @@ +name: 💡 Feature Request +description: Suggest an idea for this project, e.g., a new feature, an improvement to an existing feature, or a new integration +labels: ["Feature"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! By + submitting this issue, you agree to follow our + [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + - type: textarea + id: problem + attributes: + label: Problem + description: | + What's the problem this feature would solve? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Solution + description: | + Describe your preferred solution to this problem. Include any + alternative solutions or features you've considered if applicable. + Include screenshots or designs if they would help + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: | + Describe the feature in more detail. You can include related issues, + helpful background knowledge, related documentation, or anything else + that will help + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/interal_issue_template.yml b/.github/ISSUE_TEMPLATE/interal_issue_template.yml new file mode 100644 index 00000000..88f9e957 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/interal_issue_template.yml @@ -0,0 +1,38 @@ +name: 🔧 Internal Change +description: Suggest an Internal Change, e.g., documentation, dependencies, a code refactor +labels: ["Task"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this internal change + suggestion! By submitting this issue, you agree to follow our + [Code of Conduct](https://about.utdnebula.com/docs/code-of-conduct/) + - type: textarea + id: problem + attributes: + label: Problem + description: | + What's the problem this change would solve? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Solution + description: | + Describe your preferred solution to this problem. Include any + alternative solutions or features you've considered if applicable. + Include screenshots or designs if they would help + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: | + Describe the change in more detail. You can include related issues, + helpful background knowledge, related documentation, or anything else + that will help + validations: + required: false \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..2dfbbc29 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ + + +### Description + + + + +### Testing + + + + +### AI Disclosure + + + + +### Checklist + + +- [x] Create this PR +- [ ] Perform final self-review From 6eae172bab232a1c913acab8f89d81e695fc7eab Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 19 Aug 2026 12:22:17 -0500 Subject: [PATCH 02/73] Move feature request and internal issue to a single line --- .../feature_request_issue_template.yml | 20 +++++-------------- .../ISSUE_TEMPLATE/interal_issue_template.yml | 20 +++++-------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml index a63db776..a0b71907 100644 --- a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml @@ -4,35 +4,25 @@ labels: ["Feature"] body: - type: markdown attributes: - value: | - Thanks for taking the time to fill out this feature request! By - submitting this issue, you agree to follow our - [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) + value: Thanks for taking the time to fill out this feature request! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) - type: textarea id: problem attributes: label: Problem - description: | - What's the problem this feature would solve? + description: What's the problem this feature would solve? validations: required: true - type: textarea id: solution attributes: label: Solution - description: | - Describe your preferred solution to this problem. Include any - alternative solutions or features you've considered if applicable. - Include screenshots or designs if they would help + description: Describe your preferred solution to this problem. Include any alternative solutions or features you've considered if applicable. Include screenshots or designs if they would help validations: required: true - type: textarea id: additional-context attributes: label: Additional Context - description: | - Describe the feature in more detail. You can include related issues, - helpful background knowledge, related documentation, or anything else - that will help + description: Describe the feature in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help validations: - required: false \ No newline at end of file + required: false diff --git a/.github/ISSUE_TEMPLATE/interal_issue_template.yml b/.github/ISSUE_TEMPLATE/interal_issue_template.yml index 88f9e957..a91ec873 100644 --- a/.github/ISSUE_TEMPLATE/interal_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/interal_issue_template.yml @@ -4,35 +4,25 @@ labels: ["Task"] body: - type: markdown attributes: - value: | - Thanks for taking the time to fill out this internal change - suggestion! By submitting this issue, you agree to follow our - [Code of Conduct](https://about.utdnebula.com/docs/code-of-conduct/) + value: Thanks for taking the time to fill out this internal change suggestion! By submitting this issue, you agree to follow our [Code of Conduct](https://nebula-labs.atlassian.net/wiki/x/vAA-DQ) - type: textarea id: problem attributes: label: Problem - description: | - What's the problem this change would solve? + description: What's the problem this change would solve? validations: required: true - type: textarea id: solution attributes: label: Solution - description: | - Describe your preferred solution to this problem. Include any - alternative solutions or features you've considered if applicable. - Include screenshots or designs if they would help + description: Describe your preferred solution to this problem. Include any alternative solutions or features you've considered if applicable. Include screenshots or designs if they would help validations: required: true - type: textarea id: additional-context attributes: label: Additional Context - description: | - Describe the change in more detail. You can include related issues, - helpful background knowledge, related documentation, or anything else - that will help + description: Describe the change in more detail. You can include related issues, helpful background knowledge, related documentation, or anything else that will help validations: - required: false \ No newline at end of file + required: false From f32b1491e73952172053ed191bd4f472f391506a Mon Sep 17 00:00:00 2001 From: Isoscelestial Date: Wed, 2 Sep 2026 15:00:50 -0500 Subject: [PATCH 03/73] Fix typos and tweak capitalization --- .../{interal_issue_template.yml => internal_issue_template.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/ISSUE_TEMPLATE/{interal_issue_template.yml => internal_issue_template.yml} (94%) diff --git a/.github/ISSUE_TEMPLATE/interal_issue_template.yml b/.github/ISSUE_TEMPLATE/internal_issue_template.yml similarity index 94% rename from .github/ISSUE_TEMPLATE/interal_issue_template.yml rename to .github/ISSUE_TEMPLATE/internal_issue_template.yml index a91ec873..c3c374fc 100644 --- a/.github/ISSUE_TEMPLATE/interal_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/internal_issue_template.yml @@ -1,5 +1,5 @@ name: 🔧 Internal Change -description: Suggest an Internal Change, e.g., documentation, dependencies, a code refactor +description: Suggest an internal change, e.g., documentation, dependencies, a code refactor labels: ["Task"] body: - type: markdown From be9efc176f75d7676569b180d43909ffbca9a96f Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 8 Sep 2026 16:13:24 -0500 Subject: [PATCH 04/73] Add first draft of project architecture and structure docs --- dev-docs/project-architecture.md | 61 ++++++++++++++++++++++++++++++++ dev-docs/project-structure.md | 26 ++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 dev-docs/project-architecture.md create mode 100644 dev-docs/project-structure.md diff --git a/dev-docs/project-architecture.md b/dev-docs/project-architecture.md new file mode 100644 index 00000000..77bd06fb --- /dev/null +++ b/dev-docs/project-architecture.md @@ -0,0 +1,61 @@ +# API Architecture +Nebula API provides UTD data for others to use, including information on courses, professors, events, and more. + +## API Overview +Here's a quick look at Nebula API. + +### REST API +Currently, the Nebula API is a RESTful API. [What does that mean?](https://aws.amazon.com/what-is/restful-api/) + +The Nebula API offers information about the following: +- Courses +- Professors +- Sections +- Grades +- Comet Calendar Events +- Mazevo Events +- Astra Events +- Club Event - provided by UTD Clubs +- Rooms +- Discounts + +> [!NOTE] +> Nebula API powers only UTD Trends. UTD Clubs and Notebook have their own API internal to their own projects. Specifically, the Clubs endpoints are powered by the internal Clubs database. + +# API Diagram +``` mermaid +flowchart LR + A((Nebula API)) --> B((REST)) + C[(Club DB)] --> A + D[(Mongo DB)] --> A + F@{shape: bucket, label: "S3"}--> A +``` + +## API Documentation +We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes. + +If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. + +## Languages and Core Technologies +### Golang +[Tour of Go](https://go.dev/tour/welcome/1) - Start here if you're new to Golang. +[Documentation](https://go.dev/ref/spec) - For more technical details. + +The main language we use for Nebula API and the API tools. + +### MongoDB +[Go Mongo Driver Documentation](https://www.mongodb.com/docs/drivers/go/current/) - For using MongoDB with Golang. + +Nebula API stores the majority of its data in a MongoDB database. We interact with the Mongo database with the Mongo Go driver. + +## Libraries + +### Gin +[Documentation](https://gin-gonic.com/en/docs/) + +Gin is a HTTP web framework for Golang that allows to build or RESTful API. + +### Swagger +[Our Swagger API Docs](https://api.utdnebula.com/swagger/index.html) + +Swagger is responsible for auto-generating our documentation for our API endpoints. diff --git a/dev-docs/project-structure.md b/dev-docs/project-structure.md new file mode 100644 index 00000000..b13737e4 --- /dev/null +++ b/dev-docs/project-structure.md @@ -0,0 +1,26 @@ +# Project Structure +This file provides a brief overview of important directories and files. + +```text +nebula-api/ +├── .github/ # Configuration for the GitHub repo. Used for GitHub workflows. +├── dev-docs/ # Pages for developer wiki documentation. +├── rest/ # Directory for our RESTful API endpoints. +│ ├── configs/ # Congfiguration to set up for endpoints. +│ ├── controllers/ # Main part of API. Handles HTTP requests and responds to them. +│ ├── docs/ # Auto-generated docs on API routes from Swagger. +│ ├── responses/ # Was used for cloud storage endpoints. No longer used. +│ ├── routes/ # Defines all possible API routes. +│ ├── schema/ # Defines structure for the data. Shared with api-tools. +│ ├── Dockerfile # Configuration for building a container image for Nebula API. +│ └── server.go # Initializes API endpoints +├── .env.template # Template for environment variables used in this project. +├── .gitignore # For specifying files we do not want GitHub to track. +├── build.bat # For building Nebula API on Windows. +├── go.mod # For Go dependencies. +├── go.sum # Also for Go dependencies. +├── Makefile # For building Nebula API on Mac and Linux. +├── README.me # Documentation mainly for users of Nebula API. +├── update-gateway.bat # For updating the API gateway configuration on Windows. +└── update-gateway.sh # For updating the API gateway configuration on Mac or Linux. +``` From d632040d4fb2eb0c48f5a9395b3f2b71f10a1d0a Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 8 Sep 2026 16:15:10 -0500 Subject: [PATCH 05/73] Remove redundant repository structure from README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index df891496..91eebb55 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,6 @@ Create your own fork by [forking this repository](https://docs.github.com/en/pul Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) -## Repository Structure - -- `rest/` - REST API service implementation -- `internal/` - Shared schemas, models, and utilities across services -- `Makefile` & `build.bat` - Root-level build and development scripts - ## Building ### Requirements - [Golang 1.26 or Higher](https://go.dev/dl/) From 75951a6845bae69fc053aded106dcd08e23d9544 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2026 00:08:43 +0000 Subject: [PATCH 06/73] Bump google.golang.org/grpc from 1.83.1 to 1.83.2 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.83.1 to 1.83.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.83.1...v1.83.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-version: 1.83.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 231a939b..8654edf7 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,7 @@ require ( google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect - google.golang.org/grpc v1.83.1 // indirect + google.golang.org/grpc v1.83.2 // indirect ) require ( diff --git a/go.sum b/go.sum index 24da4091..70c69e64 100644 --- a/go.sum +++ b/go.sum @@ -303,8 +303,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1: google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= -google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y= -google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From c9aaaaa0cf3f664d9bc48bcd49250e49de8ee07b Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 10 Sep 2026 18:27:44 -0500 Subject: [PATCH 07/73] Update project architecture and structure docs --- dev-docs/project-architecture.md | 61 ---------------- docs/project-architecture.md | 92 +++++++++++++++++++++++++ {dev-docs => docs}/project-structure.md | 2 +- 3 files changed, 93 insertions(+), 62 deletions(-) delete mode 100644 dev-docs/project-architecture.md create mode 100644 docs/project-architecture.md rename {dev-docs => docs}/project-structure.md (96%) diff --git a/dev-docs/project-architecture.md b/dev-docs/project-architecture.md deleted file mode 100644 index 77bd06fb..00000000 --- a/dev-docs/project-architecture.md +++ /dev/null @@ -1,61 +0,0 @@ -# API Architecture -Nebula API provides UTD data for others to use, including information on courses, professors, events, and more. - -## API Overview -Here's a quick look at Nebula API. - -### REST API -Currently, the Nebula API is a RESTful API. [What does that mean?](https://aws.amazon.com/what-is/restful-api/) - -The Nebula API offers information about the following: -- Courses -- Professors -- Sections -- Grades -- Comet Calendar Events -- Mazevo Events -- Astra Events -- Club Event - provided by UTD Clubs -- Rooms -- Discounts - -> [!NOTE] -> Nebula API powers only UTD Trends. UTD Clubs and Notebook have their own API internal to their own projects. Specifically, the Clubs endpoints are powered by the internal Clubs database. - -# API Diagram -``` mermaid -flowchart LR - A((Nebula API)) --> B((REST)) - C[(Club DB)] --> A - D[(Mongo DB)] --> A - F@{shape: bucket, label: "S3"}--> A -``` - -## API Documentation -We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes. - -If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. - -## Languages and Core Technologies -### Golang -[Tour of Go](https://go.dev/tour/welcome/1) - Start here if you're new to Golang. -[Documentation](https://go.dev/ref/spec) - For more technical details. - -The main language we use for Nebula API and the API tools. - -### MongoDB -[Go Mongo Driver Documentation](https://www.mongodb.com/docs/drivers/go/current/) - For using MongoDB with Golang. - -Nebula API stores the majority of its data in a MongoDB database. We interact with the Mongo database with the Mongo Go driver. - -## Libraries - -### Gin -[Documentation](https://gin-gonic.com/en/docs/) - -Gin is a HTTP web framework for Golang that allows to build or RESTful API. - -### Swagger -[Our Swagger API Docs](https://api.utdnebula.com/swagger/index.html) - -Swagger is responsible for auto-generating our documentation for our API endpoints. diff --git a/docs/project-architecture.md b/docs/project-architecture.md new file mode 100644 index 00000000..de520f78 --- /dev/null +++ b/docs/project-architecture.md @@ -0,0 +1,92 @@ +# API Architecture +Nebula API provides UTD data for others to use, including information on courses, professors, events, and more. + +## API Overview +Here's a quick look at Nebula API. + +### REST API +The Nebula API is a RESTful API. [What's an API? What does that mean?](https://aws.amazon.com/what-is/restful-api/) + +Currently, the Nebula API offers information about the following: +- Courses +- Professors +- Sections +- Grades +- Comet Calendar Events +- Mazevo Events +- Astra Events +- Club Events - provided by UTD Clubs + Rooms +- Discounts + +> [!NOTE] +> Nebula API powers only UTD Trends and UTD Rooms. UTD Clubs and Notebook have their own API internal to their own projects. Specifically, the Clubs endpoints are powered by the internal Clubs database. + +All of this information (except for club events) is provided by [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. + +### How does Nebula API work? + +When a user sends a HTTP request, Gin handles the request by matching the URL request to one of our routes. + +Then, Gin passes the request's parameters to the appropriate controller. The controller uses those parameters with Mongo's Go Driver to construct a query filter and execute it against the Mongo database. + +The database fetches the requested data and then returns the data back to the controller. The controller sends the data and the outcome of the request, in the form of some HTTP status code, back to Gin. + +Gin creates a HTTP response with the data and HTTP status code, and finally, Gin sends the HTTP response back to the user. + + +### API Diagram +``` mermaid +flowchart LR + A[User] --HTTP Request--> B + B[Gin] --*gin.Context--> C + C[Controllers] --"Constructed + Query Filter"--> D + D[("Mongo + Database")] + D --Requested Data--> C + C --"Data and + Status Code"--> B + B --HTTP Response--> A +``` + +## API Documentation +We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes. + +If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. + +## Languages and Core Technologies +### Golang +[Tour of Go](https://go.dev/tour/welcome/1) - Start here if you're new to Golang. +[Effective Go](https://go.dev/doc/effective_go) - Guide for writing clear Golang code. +[Go Documentation](https://go.dev/ref/spec) - For more technical details about Golang. + +The main language we use for Nebula API and the API tools. + +### MongoDB +[Go Mongo Driver Documentation](https://www.mongodb.com/docs/drivers/go/current/) - For using MongoDB with Golang. + +Nebula API stores the majority of its data in a MongoDB database. We interact with the Mongo database with the Mongo Go driver. + +## Libraries + +### Gin +[Documentation](https://gin-gonic.com/en/docs/) - For more information regarding Gin. + +Gin is a HTTP web framework for Golang that allows to build the Nebula API. + +### Swagger +[Our API Docs](https://api.utdnebula.com/swagger/index.html) - Generated by Swagger. +[Documentation](https://swagger.io/docs/) - For more information regarding Swagger. + +Swagger is responsible for auto-generating our documentation for our API endpoints. + +### Sentry +[Documentation](https://docs.sentry.io/get-started/guides/) - Sentry for Golang. + +Sentry provides performance and error monitoring to help us find and fix problems. + +### Google Cloud +[Documentation](https://pkg.go.dev/cloud.google.com/go#section-readme) - + +We use Google Cloud for our email and storage endpoints. \ No newline at end of file diff --git a/dev-docs/project-structure.md b/docs/project-structure.md similarity index 96% rename from dev-docs/project-structure.md rename to docs/project-structure.md index b13737e4..86c5dba7 100644 --- a/dev-docs/project-structure.md +++ b/docs/project-structure.md @@ -4,7 +4,7 @@ This file provides a brief overview of important directories and files. ```text nebula-api/ ├── .github/ # Configuration for the GitHub repo. Used for GitHub workflows. -├── dev-docs/ # Pages for developer wiki documentation. +├── docs/ # Pages for developer wiki documentation. ├── rest/ # Directory for our RESTful API endpoints. │ ├── configs/ # Congfiguration to set up for endpoints. │ ├── controllers/ # Main part of API. Handles HTTP requests and responds to them. From f6e5eb420950774febd3813695f627fcc0275d12 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 10 Sep 2026 18:34:27 -0500 Subject: [PATCH 08/73] Move contribute stuff off of README.md --- README.md | 72 -------------------------------------- docs/How-to-Contribute.md | 73 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 72 deletions(-) create mode 100644 docs/How-to-Contribute.md diff --git a/README.md b/README.md index 91eebb55..ed81b813 100644 --- a/README.md +++ b/README.md @@ -22,75 +22,3 @@ Contributions are welcome! This project uses the MIT License. Please visit our [Discord](https://discord.utdnebula.com) and talk to us if you'd like to contribute! Don't be afraid to ask for help! - -### How to Contribute - -Create your own fork by [forking this repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository) - -[Clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) your forked repository. (Don't forget to install Git if you haven't already) - -Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) - -## Building -### Requirements -- [Golang 1.26 or Higher](https://go.dev/dl/) - -### Building for Windows - -Setup Go Dependencies with: -```cmd -.\build.bat setup -``` - -Build with: -```cmd -.\build.bat build -``` - -This will create an executable named `rest-api.exe` in the root directory. - -Run with: -```cmd -.\rest-api.exe -``` -> Note: Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. - -### Building for macOS, Linux, and WSL - -Setup Go dependencies with: -```bash -make setup -``` - -Build with: -```bash -make build -``` - -This will create an executable named `rest-api` in the root directory. - -> Note: If Make fails with "swag: No such file or directory" or similar, you may need to add GOPATH/bin to your path. On Mac/Linux, use `echo 'export PATH=${PATH}:'$(go env GOPATH)'/bin' >> ~/.zshrc && source ~/.zshrc` (or `.bashrc`) to add it permanently. - -Run with: -```bash -./rest-api -``` - -## Running API locally -Copy `.env.template` to `.env` with: -```bash -cp .env.template .env -``` - -Enter Nebula MongoDB URI in `.env` (ask for help in the [Discord](https://discord.utdnebula.com)) - -Run `rest-api`: -```bash -./rest-api -``` - -Check command output to see the route serving traffic. It's likely port 8080. - -Visit `http://localhost:8080` to access nebula-api locally. - -> Storage and email routes require additional environment variables. If you're working on these routes, ask for help in the [Discord](https://discord.utdnebula.com) diff --git a/docs/How-to-Contribute.md b/docs/How-to-Contribute.md new file mode 100644 index 00000000..26cca4b6 --- /dev/null +++ b/docs/How-to-Contribute.md @@ -0,0 +1,73 @@ +Moving stuff off of README.md + +### How to Contribute + +Create your own fork by [forking this repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository) + +[Clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) your forked repository. (Don't forget to install Git if you haven't already) + +Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) + +## Building +### Requirements +- [Golang 1.26 or Higher](https://go.dev/dl/) + +### Building for Windows + +Setup Go Dependencies with: +```cmd +.\build.bat setup +``` + +Build with: +```cmd +.\build.bat build +``` + +This will create an executable named `rest-api.exe` in the root directory. + +Run with: +```cmd +.\rest-api.exe +``` +> Note: Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. + +### Building for macOS, Linux, and WSL + +Setup Go dependencies with: +```bash +make setup +``` + +Build with: +```bash +make build +``` + +This will create an executable named `rest-api` in the root directory. + +> Note: If Make fails with "swag: No such file or directory" or similar, you may need to add GOPATH/bin to your path. On Mac/Linux, use `echo 'export PATH=${PATH}:'$(go env GOPATH)'/bin' >> ~/.zshrc && source ~/.zshrc` (or `.bashrc`) to add it permanently. + +Run with: +```bash +./rest-api +``` + +## Running API locally +Copy `.env.template` to `.env` with: +```bash +cp .env.template .env +``` + +Enter Nebula MongoDB URI in `.env` (ask for help in the [Discord](https://discord.utdnebula.com)) + +Run `rest-api`: +```bash +./rest-api +``` + +Check command output to see the route serving traffic. It's likely port 8080. + +Visit `http://localhost:8080` to access nebula-api locally. + +> Storage and email routes require additional environment variables. If you're working on these routes, ask for help in the [Discord](https://discord.utdnebula.com) From d53ed74ea9986cb307f1f48abf7be845fd017721 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 10 Sep 2026 19:18:24 -0500 Subject: [PATCH 09/73] Rename files --- docs/{project-architecture.md => Project-Architecture.md} | 0 docs/{project-structure.md => Project-Structure.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename docs/{project-architecture.md => Project-Architecture.md} (100%) rename docs/{project-structure.md => Project-Structure.md} (100%) diff --git a/docs/project-architecture.md b/docs/Project-Architecture.md similarity index 100% rename from docs/project-architecture.md rename to docs/Project-Architecture.md diff --git a/docs/project-structure.md b/docs/Project-Structure.md similarity index 100% rename from docs/project-structure.md rename to docs/Project-Structure.md From d029ba2cc99b101d36fb7b879491f09be7032227 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 15 Sep 2026 12:51:32 -0500 Subject: [PATCH 10/73] Add the other docs --- docs/Getting-Started.md | 147 +++++++++++++++++++++++++++++++++++ docs/Home.md | 17 ++++ docs/How-to-Contribute.md | 79 ++++++++----------- docs/Project-Architecture.md | 10 ++- docs/Project-Structure.md | 4 + docs/Troubleshooting.md | 15 ++++ docs/_Sidebar.md | 10 +++ 7 files changed, 233 insertions(+), 49 deletions(-) create mode 100644 docs/Getting-Started.md create mode 100644 docs/Home.md create mode 100644 docs/Troubleshooting.md create mode 100644 docs/_Sidebar.md diff --git a/docs/Getting-Started.md b/docs/Getting-Started.md new file mode 100644 index 00000000..fefa825c --- /dev/null +++ b/docs/Getting-Started.md @@ -0,0 +1,147 @@ +# Getting Started with Nebula API + +Here's how to set up your local development environment. + +## Prerequisites + +Ensure you have the following installed: + +- Git - For version control + - If you've never used git, need a refresher, or need help setting it up, please check out [Nebula's Git Workshop](https://github.com/UTDNebula/git-workshop). +- Go - For building and running + - You can install from the [Go website](https://go.dev/dl/), or from [Homebrew](https://brew.sh/) or another package manager for automatic updates +- Make _(Linux/macOS)_ - For build automation + - Pre-installed on macOS (via `xcode-select --install`) and most Linux distributions (`build-essential`) +- Docker _(Optional)_ - For running containerized runners locally + +**Make** is a build automation tool. Feel free to check out [`Makefile`](../Makefile) to see exactly what's being run. + +If you're using Windows, instead of using `make`, you can also use our [`build.bat`](../build.bat) file. When you see any command starting with `make`, you can instead use `.\build.bat`. +For example instead of `make setup`, you can run `.\build.bat setup`. + +## Local Setup + +### Clone the Repository + +Clone the repository with `git clone`, and then, `cd` into the project directory or open it in your preferred code editor. + +**HTTPS:** + +```bash +git clone https://github.com/UTDNebula/nebula-api.git +cd nebula-api +``` + +or + +**SSH:** + +```bash +git clone git@github.com:UTDNebula/nebula-api.git +cd nebula-api +``` + +Now open the cloned project in your code editor! + +### Install Development Tooling + +Install the Go static analysis and formatting tools (`staticcheck` and `goimports`): + +```bash +make setup +``` + +or + +```cmd +.\build.bat setup +``` + +If you installed **Go** with [**Homebrew**](https://brew.sh/), you need to add Go tools to your path for tools like `staticcheck` and others to work. + +- **For zsh** (the default shell on MacOS) + + ```bash + echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.zshrc && source ~/.zshrc + ``` + +- **For bash** (the default shell on most Linux distributions) + + ```bash + echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.bashrc && source ~/.bashrc + ``` + +- **For fish** + + ```bash + echo 'fish_add_path (go env GOPATH)/bin' >> ~/.config/fish/config.fish + ``` + +### Configure Environment Variables + +Make a file called `.env` at the root of the project, and copy the contents of `.env.template` into it. Some parts in `nebula-api` require certain environment variables, which you can fill in `.env`. +If you're not sure what to put, please try contacting one of our members through [Discord](https://discord.utdnebula.com). + +### Run Code Verification & Formatting + +Check your code with: + +```bash +make check +``` + +or + +```cmd +.\build.bat check +``` + +You'll want to run this frequently while developing. + +### Build the CLI Executable + +Compile the Go source code into a runnable binary (`./rest-api` on Linux/macOS, `rest-api.exe` on Windows): + +```bash +make build +``` + +or + +```cmd +.\build.bat build +``` + +### Verify with Automated Tests + +Run the test suite to confirm your environment is ready: + +```bash +make test +``` + +or + +```cmd +.\build.bat test +``` + +If all tests pass, congratulations! Your local development environment is ready. + +### Running the API locally + +To run `rest-api` locally, use: + +```bash +./rest-api +``` + +Check command output to see the route serving traffic. It's likely port 8080. + +Visit `http://localhost:8080` to access nebula-api locally. + +> [!NOTE] Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. + +## Next Step + +Now that your environment is running, it's time to dive deeper. Check out [Project-Architecture.md](Project-Architecture.md) \ No newline at end of file diff --git a/docs/Home.md b/docs/Home.md new file mode 100644 index 00000000..35727db6 --- /dev/null +++ b/docs/Home.md @@ -0,0 +1,17 @@ +# Nebula API Developer Documentation + +Welcome to the **Nebula API Developer Documentation**! + +These docs are intended for developers of `nebula-api` rather than users. For usage instructions, see [README.md](../README.md). + +If you are a new developer, check out the pages under "Getting Started" in the Sidebar! + +## Need Help? + +Join [our community on Discord](https://discord.utdnebula.com) and ask questions in the `#api-help` or the development channels. We are always happy to help! + +## Found something you want to change on these docs? + +Don't edit these docs manually on Github. Instead, suggest a change by [creating an issue](../issues), or [opening a pull request](../pulls) with your changes. + +These docs are automatically generated from the `docs/` folder of this repository. \ No newline at end of file diff --git a/docs/How-to-Contribute.md b/docs/How-to-Contribute.md index 26cca4b6..0dbd9f10 100644 --- a/docs/How-to-Contribute.md +++ b/docs/How-to-Contribute.md @@ -1,73 +1,60 @@ -Moving stuff off of README.md +# How to Contribute -### How to Contribute +Thank you for your interest in contributing to `nebula-api`! Here's how to contribute to our project. +Don't worry if you don't quite know what you're doing, we're here to help. We don't expect perfection and appreciate anything you can do to help! -Create your own fork by [forking this repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository) +## Find something to work on -[Clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) your forked repository. (Don't forget to install Git if you haven't already) +Look at our current issues, or make your own on our [issues page](https://github.com/UTDNebula/nebula-api/issues). -Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) +For beginner issues, please write the code yourself rather than using AI to generate it. These issues are designed to help new members learn the codebase and build familiarity with the project. We allow AI in Nebula Labs, but review our [AI Policy](https://nebula-labs.atlassian.net/wiki/spaces/NLG/pages/1135607810/AI+Policy) for more information on acceptable uses of AI. -## Building -### Requirements -- [Golang 1.26 or Higher](https://go.dev/dl/) +Once you find an issue, write a comment asking if you can work on it. -### Building for Windows +If you're unsure about something, **don't hesitate to ask for help**. We're happy to answer questions and help you work through issues. You can reach out on GitHub, Discord, or in person. -Setup Go Dependencies with: -```cmd -.\build.bat setup -``` +## Create a branch -Build with: -```cmd -.\build.bat build -``` +Nebula recruits and members should make their changes on a branch, external contributors should work off of a fork as they do not have permission to make a branch. -This will create an executable named `rest-api.exe` in the root directory. +## Make Your Changes -Run with: -```cmd -.\rest-api.exe -``` -> Note: Some users have experienced issues with Windows Defender or other antivirus blocking `rest-api.exe` from reading files, editing files, or causing slowed performance. Consider adding an exception to your `nebula-api` folder. +It's time to code! -### Building for macOS, Linux, and WSL +Don't forget to format and check your code. We have helper scripts with **Make** and **build.bat**: -Setup Go dependencies with: -```bash -make setup -``` +Check your code with -Build with: ```bash -make build +make check ``` -This will create an executable named `rest-api` in the root directory. - -> Note: If Make fails with "swag: No such file or directory" or similar, you may need to add GOPATH/bin to your path. On Mac/Linux, use `echo 'export PATH=${PATH}:'$(go env GOPATH)'/bin' >> ~/.zshrc && source ~/.zshrc` (or `.bashrc`) to add it permanently. +or -Run with: -```bash -./rest-api +```cmd +.\build.bat check ``` -## Running API locally -Copy `.env.template` to `.env` with: +Run tests with + ```bash -cp .env.template .env +make test ``` -Enter Nebula MongoDB URI in `.env` (ask for help in the [Discord](https://discord.utdnebula.com)) +or -Run `rest-api`: -```bash -./rest-api +```cmd +.\build.bat test ``` -Check command output to see the route serving traffic. It's likely port 8080. +We would appreciate if you make a draft Pull Request as your working on it, so we can see your progress and help you out! + +## Making a Pull Request (PR) + +Open [our Pull Request Page](https://github.com/UTDNebula/nebula-api/pulls), and create a PR. If you're not finished, you can make your PR a draft. + +Maintainers will review your PR and may provide suggestions or request changes before approval. -Visit `http://localhost:8080` to access nebula-api locally. +## Next Step -> Storage and email routes require additional environment variables. If you're working on these routes, ask for help in the [Discord](https://discord.utdnebula.com) +You have everything you need to start, but do feel free to check out other pages first. \ No newline at end of file diff --git a/docs/Project-Architecture.md b/docs/Project-Architecture.md index de520f78..213debf0 100644 --- a/docs/Project-Architecture.md +++ b/docs/Project-Architecture.md @@ -5,7 +5,7 @@ Nebula API provides UTD data for others to use, including information on courses Here's a quick look at Nebula API. ### REST API -The Nebula API is a RESTful API. [What's an API? What does that mean?](https://aws.amazon.com/what-is/restful-api/) +The Nebula API is a RESTful API. [What's an API? What does RESTful mean?](https://aws.amazon.com/what-is/restful-api/) Currently, the Nebula API offers information about the following: - Courses @@ -87,6 +87,10 @@ Swagger is responsible for auto-generating our documentation for our API endpoin Sentry provides performance and error monitoring to help us find and fix problems. ### Google Cloud -[Documentation](https://pkg.go.dev/cloud.google.com/go#section-readme) - +[Documentation](https://pkg.go.dev/cloud.google.com/go#section-readme) - Google Cloud Services for Golang. -We use Google Cloud for our email and storage endpoints. \ No newline at end of file +We use Google Cloud for our email and storage endpoints. + +## Next Step + +See [Project-Structure.md](Project-Structure.md) \ No newline at end of file diff --git a/docs/Project-Structure.md b/docs/Project-Structure.md index 86c5dba7..caa7bae6 100644 --- a/docs/Project-Structure.md +++ b/docs/Project-Structure.md @@ -24,3 +24,7 @@ nebula-api/ ├── update-gateway.bat # For updating the API gateway configuration on Windows. └── update-gateway.sh # For updating the API gateway configuration on Mac or Linux. ``` + +## Next Step + +See [How-to-Contribute.md](How-to-Contribute.md) \ No newline at end of file diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md new file mode 100644 index 00000000..423b96da --- /dev/null +++ b/docs/Troubleshooting.md @@ -0,0 +1,15 @@ +# Troubleshooting + +Here are some solutions to common problems. + +## KEY is missing from .env + +Ensure you have filled environment variables in the .env file. If you need guidance on how to set up .env, please ask for help. + +## Port 8080 is already in use + +Close applications that might use port 8080 (e.g., Steam). If you're not sure which process is currently using port 8080, please ask for help. + +## Still Stuck? + +Ask for help on [Discord](https://discord.utdnebula.com)! \ No newline at end of file diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md new file mode 100644 index 00000000..0fb15416 --- /dev/null +++ b/docs/_Sidebar.md @@ -0,0 +1,10 @@ +## Getting Started + +- [Getting Started](Getting-Started.md) +- [Project Architecture](Project-Architecture.md) +- [Project Structure](Project-Structure.md) +- [How to Contribute](How-to-Contribute.md) + +## References + +- [Troubleshooting](Troubleshooting.md) \ No newline at end of file From 373930086768b499b723be33f82baf662c5302bf Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 15 Sep 2026 13:17:33 -0500 Subject: [PATCH 11/73] Update README.md --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed81b813..ddff435e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,18 @@ _A database for some really useful UTD data collected by our [tools](https://git Project maintained by [Nebula Labs](https://about.utdnebula.com). -## Documentation +## Quick Navigation + +- [API Documentation](https://api.utdnebula.com/swagger/index.html) +- [Developer Wiki](docs/Home.md) +- [Getting Started Guide](/docs/Getting-Started.md) +- [Project Architecture](/docs/Project-Architecture.md) +- [Project Structure](/docs/Project-Structure.md) +- [Contributing Guide](/docs/How-to-Contribute.md) +- [Troubleshooting & FAQ](/docs/Troubleshooting.md) +- [Discord Community](https://discord.utdnebula.com) + +## API Documentation Documentation for the current production API can be found [here.](https://api.utdnebula.com/swagger/index.html) @@ -21,4 +32,8 @@ Contributions are welcome! This project uses the MIT License. -Please visit our [Discord](https://discord.utdnebula.com) and talk to us if you'd like to contribute! Don't be afraid to ask for help! +Please visit our [Developer Wiki](docs/Home.md) to get started! + +## Community & Support + +Have questions, suggestions, or want to contribute? Reach out on our [Discord](https://discord.utdnebula.com)! From 5875c367cfebe59c435e7cbe1ec704066bdf787e Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 15 Sep 2026 13:27:20 -0500 Subject: [PATCH 12/73] Fix links in Home.md --- docs/Home.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Home.md b/docs/Home.md index 35727db6..4847cf7b 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -12,6 +12,6 @@ Join [our community on Discord](https://discord.utdnebula.com) and ask questions ## Found something you want to change on these docs? -Don't edit these docs manually on Github. Instead, suggest a change by [creating an issue](../issues), or [opening a pull request](../pulls) with your changes. +Don't edit these docs manually on Github. Instead, suggest a change by [creating an issue](https://github.com/UTDNebula/nebula-api/issues), or [opening a pull request](https://github.com/UTDNebula/nebula-api/pulls) with your changes. These docs are automatically generated from the `docs/` folder of this repository. \ No newline at end of file From b46ad8210afab7da397a2aa3e437dba5a9b9ae34 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 17 Sep 2026 18:24:45 -0500 Subject: [PATCH 13/73] Clarify .env instructions --- docs/Getting-Started.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/Getting-Started.md b/docs/Getting-Started.md index fefa825c..5867c679 100644 --- a/docs/Getting-Started.md +++ b/docs/Getting-Started.md @@ -79,9 +79,14 @@ If you installed **Go** with [**Homebrew**](https://brew.sh/), you need to add G ### Configure Environment Variables -Make a file called `.env` at the root of the project, and copy the contents of `.env.template` into it. Some parts in `nebula-api` require certain environment variables, which you can fill in `.env`. +First, make a file called `.env` at the root of the project. + +Then, copy the contents of `.env.template` into it. Some parts in `nebula-api` require certain environment variables, which you can fill in `.env`. + If you're not sure what to put, please try contacting one of our members through [Discord](https://discord.utdnebula.com). +> [!IMPORTANT] Do NOT put any environment variables into `.env.template`. + ### Run Code Verification & Formatting Check your code with: From 20ac8d466185391770da24e045e512797641c7e1 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 17 Sep 2026 18:26:37 -0500 Subject: [PATCH 14/73] Add the wiki workflow --- .github/workflows/wiki.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/wiki.yml diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml new file mode 100644 index 00000000..38d21aff --- /dev/null +++ b/.github/workflows/wiki.yml @@ -0,0 +1,27 @@ +name: Publish Wiki + +on: + push: + branches: [develop] + paths: + - 'docs/**' + workflow_dispatch: + +concurrency: + group: publish-wiki + cancel-in-progress: true + +permissions: + contents: write + +jobs: + publish-wiki: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Sync docs to GitHub Wiki + uses: Andrew-Chen-Wang/github-wiki-action@v5 + with: + path: docs/ \ No newline at end of file From a12353b838768e3d7366f5a0d95a8d86f691ee72 Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 13:40:22 -0500 Subject: [PATCH 15/73] config(sentry): Read the Sentry DSN from SENTRY_DSN Initialize Sentry with the DSN from the environment instead of a hardcoded value. An unset SENTRY_DSN leaves the DSN empty, which the SDK handles by installing a no-op transport, so development environments stop reporting to Sentry without needing SENTRY_DSN="" in every contributor's .env. --- .env.template | 2 ++ rest/configs/env.go | 8 ++++++++ rest/configs/sentry_test.go | 37 +++++++++++++++++++++++++++++++++++++ rest/server.go | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 rest/configs/sentry_test.go diff --git a/.env.template b/.env.template index 27962beb..9bdce2fd 100644 --- a/.env.template +++ b/.env.template @@ -13,6 +13,8 @@ CLUBS_DB_URI= # SENRTY SENTRY_ENVIRONMENT=development +# Leave unset outside of production -- an empty DSN disables Sentry +SENTRY_DSN= # For Google Cloud Routes /storage /email (internal use only) GOOGLE_APPLICATION_CREDENTIALS= diff --git a/rest/configs/env.go b/rest/configs/env.go index 03660bb9..8fcdc669 100644 --- a/rest/configs/env.go +++ b/rest/configs/env.go @@ -115,3 +115,11 @@ func GetEnvMaxUploadSize() int64 { return limit } + +func GetEnvSentryDSN() string { + + // Sentry is disabled when initialized without a DSN, so an unset + // SENTRY_DSN keeps development errors out of Sentry. Only production + // sets this variable. + return os.Getenv("SENTRY_DSN") +} diff --git a/rest/configs/sentry_test.go b/rest/configs/sentry_test.go new file mode 100644 index 00000000..b550731a --- /dev/null +++ b/rest/configs/sentry_test.go @@ -0,0 +1,37 @@ +package configs + +import ( + "os" + "testing" +) + +func TestGetEnvSentryDSN(t *testing.T) { + + original, hadOriginal := os.LookupEnv("SENTRY_DSN") + defer func() { + if hadOriginal { + os.Setenv("SENTRY_DSN", original) + } else { + os.Unsetenv("SENTRY_DSN") + } + }() + + t.Run("Unset returns empty string", func(t *testing.T) { + + os.Unsetenv("SENTRY_DSN") + + if dsn := GetEnvSentryDSN(); dsn != "" { + t.Errorf("expected an empty DSN when SENTRY_DSN is unset, got %q", dsn) + } + }) + + t.Run("Set returns the DSN", func(t *testing.T) { + + const expected = "https://public@sentry.example.com/1" + os.Setenv("SENTRY_DSN", expected) + + if dsn := GetEnvSentryDSN(); dsn != expected { + t.Errorf("expected %q, got %q", expected, dsn) + } + }) +} diff --git a/rest/server.go b/rest/server.go index 2b8b6a57..565dad66 100644 --- a/rest/server.go +++ b/rest/server.go @@ -50,7 +50,7 @@ func main() { // Set up Sentry if err := sentry.Init(sentry.ClientOptions{ - Dsn: "https://530f8e39f757b71ab26ad1aa12e17a4d@o4504918397353984.ingest.us.sentry.io/4509397160493056", + Dsn: configs.GetEnvSentryDSN(), TracesSampleRate: 1.0, EnableTracing: true, }); err != nil { From ed47829165d3df9a0acc5dd219784909bb0d2195 Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 14:19:19 -0500 Subject: [PATCH 16/73] test: rename sentry_test.go to env_test.go per review --- rest/configs/{sentry_test.go => env_test.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rest/configs/{sentry_test.go => env_test.go} (100%) diff --git a/rest/configs/sentry_test.go b/rest/configs/env_test.go similarity index 100% rename from rest/configs/sentry_test.go rename to rest/configs/env_test.go From 5a6926a264f11de7a8a465b91da7fdc8f371c5be Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Sat, 19 Sep 2026 16:12:10 -0500 Subject: [PATCH 17/73] fix: return 404 for missing section course (#433) --- rest/controllers/section.go | 4 ++++ rest/controllers/section_test.go | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 rest/controllers/section_test.go diff --git a/rest/controllers/section.go b/rest/controllers/section.go index 3c70c931..e23cf80f 100644 --- a/rest/controllers/section.go +++ b/rest/controllers/section.go @@ -200,6 +200,10 @@ func sectionCourse(flag string, c *gin.Context) { case "Search": respond(c, http.StatusOK, "success", sectionCourses) case "ById": + if len(sectionCourses) == 0 { + respond(c, http.StatusNotFound, "error", "No section with given ID") + return + } respond(c, http.StatusOK, "success", sectionCourses[0]) } } diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go new file mode 100644 index 00000000..775b193c --- /dev/null +++ b/rest/controllers/section_test.go @@ -0,0 +1,35 @@ +package controllers + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +func TestSectionCourseById_SectionNotFound(t *testing.T) { + gin.SetMode(gin.TestMode) + + responseRecorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(responseRecorder) + context.Request = httptest.NewRequest(http.MethodGet, "/", nil) + context.Params = []gin.Param{{Key: "id", Value: primitive.NewObjectID().Hex()}} + + SectionCourseById(context) + + if responseRecorder.Code != http.StatusNotFound { + t.Fatalf("expected status %d, got %d", http.StatusNotFound, responseRecorder.Code) + } + + var response schema.APIResponse[string] + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("decode response: %v", err) + } + if response.Data != "No section with given ID" { + t.Errorf("expected not-found message, got %q", response.Data) + } +} From 771445bf9451245ab06490732958f16847371f70 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Sat, 19 Sep 2026 17:05:18 -0500 Subject: [PATCH 18/73] test: cover section course controller scenarios --- rest/controllers/section_test.go | 77 +++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go index 775b193c..ac13e90a 100644 --- a/rest/controllers/section_test.go +++ b/rest/controllers/section_test.go @@ -11,25 +11,72 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" ) -func TestSectionCourseById_SectionNotFound(t *testing.T) { +func TestSectionCourseById(t *testing.T) { gin.SetMode(gin.TestMode) - responseRecorder := httptest.NewRecorder() - context, _ := gin.CreateTestContext(responseRecorder) - context.Request = httptest.NewRequest(http.MethodGet, "/", nil) - context.Params = []gin.Param{{Key: "id", Value: primitive.NewObjectID().Hex()}} + testCases := []struct { + name string + id string + expectedStatus int + expectedResponseMessage string + expectedData string + }{ + { + name: "ReturnCourseSuccessfully", + id: "6a8f623120b48b6efe790176", + expectedStatus: http.StatusOK, + expectedResponseMessage: "success", + }, + { + name: "InvalidMongoId", + id: "This is invalid MongoDB ID", + expectedStatus: http.StatusBadRequest, + expectedResponseMessage: `Parameter "id" is not a valid ObjectID.`, + }, + { + name: "NoSectionFound", + id: primitive.NewObjectID().Hex(), + expectedStatus: http.StatusNotFound, + expectedResponseMessage: "error", + expectedData: "No section with given ID", + }, + } - SectionCourseById(context) + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + responseRecorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(responseRecorder) + context.Request = httptest.NewRequest(http.MethodGet, "/", nil) + context.Params = []gin.Param{{Key: "id", Value: testCase.id}} - if responseRecorder.Code != http.StatusNotFound { - t.Fatalf("expected status %d, got %d", http.StatusNotFound, responseRecorder.Code) - } + SectionCourseById(context) - var response schema.APIResponse[string] - if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { - t.Fatalf("decode response: %v", err) - } - if response.Data != "No section with given ID" { - t.Errorf("expected not-found message, got %q", response.Data) + if responseRecorder.Code != testCase.expectedStatus { + t.Fatalf("expected status %d, got %d", testCase.expectedStatus, responseRecorder.Code) + } + + var response schema.APIResponse[json.RawMessage] + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("decode response: %v", err) + } + if response.Status != testCase.expectedStatus { + t.Errorf("expected response status %d, got %d", testCase.expectedStatus, response.Status) + } + if response.Message != testCase.expectedResponseMessage { + t.Errorf("expected response message %q, got %q", testCase.expectedResponseMessage, response.Message) + } + + if testCase.expectedData == "" { + return + } + + var responseData string + if err := json.Unmarshal(response.Data, &responseData); err != nil { + t.Fatalf("decode response data: %v", err) + } + if responseData != testCase.expectedData { + t.Errorf("expected response data %q, got %q", testCase.expectedData, responseData) + } + }) } } From 4281ae478889d4edc4bcb4adf56658514c96bb37 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Sat, 19 Sep 2026 17:08:35 -0500 Subject: [PATCH 19/73] docs: document missing section course response --- rest/controllers/section.go | 1 + rest/docs/docs.go | 6 ++++++ rest/docs/swagger.yaml | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/rest/controllers/section.go b/rest/controllers/section.go index e23cf80f..99fb39de 100644 --- a/rest/controllers/section.go +++ b/rest/controllers/section.go @@ -164,6 +164,7 @@ func SectionCourseSearch(c *gin.Context) { // @Success 200 {object} schema.APIResponse[schema.Course] "A course" // @Failure 500 {object} schema.APIResponse[string] "A string describing the error" // @Failure 400 {object} schema.APIResponse[string] "A string describing the error" +// @Failure 404 {object} schema.APIResponse[string] "A string describing the error" func SectionCourseById(c *gin.Context) { sectionCourse("ById", c) } diff --git a/rest/docs/docs.go b/rest/docs/docs.go index 23052745..0b58bdac 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -3078,6 +3078,12 @@ const docTemplate = `{ "$ref": "#/definitions/schema.APIResponse-string" } }, + "404": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, "500": { "description": "A string describing the error", "schema": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 261100bb..66b4b32d 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -3027,6 +3027,10 @@ paths: description: A string describing the error schema: $ref: '#/definitions/schema.APIResponse-string' + "404": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' "500": description: A string describing the error schema: From d64f0ab07d33485e1c4d390d8038544111cb2ed4 Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 18:52:48 -0500 Subject: [PATCH 20/73] test(configs): Cover the remaining env reading functions Add unit tests for GetPortString, GetEnvMongoURI, GetClubsDBUri, GetEnvLogin, GetEnvLimit and GetEnvMaxUploadSize, covering the unset, parsed, unparseable and hard-capped paths. GetEnvMongoURI and GetEnvLogin end in log.Fatalf, which would take the test binary down with them, so those cases run in a subprocess and assert the exit code. The subprocess runs from an empty directory so a contributor's own .env cannot satisfy the variable under test. --- rest/configs/env_test.go | 265 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 255 insertions(+), 10 deletions(-) diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index b550731a..c88e2339 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -2,23 +2,268 @@ package configs import ( "os" + "os/exec" "testing" ) -func TestGetEnvSentryDSN(t *testing.T) { +// unsetEnv removes a variable for the duration of the test, restoring whatever +// value it had once the test finishes. +func unsetEnv(t *testing.T, key string) { + t.Helper() + + // t.Setenv records the original value so it is restored on cleanup; the + // unset immediately afterwards is what the test actually wants. + t.Setenv(key, "") + os.Unsetenv(key) +} + +// The environment readers below exit through log.Fatalf when a required +// variable is missing, which would take the test binary down with them. Each +// case is instead run in a subprocess that calls the reader directly, so the +// exit status can be observed. +const fatalCaseVar = "NEBULA_ENV_FATAL_CASE" + +var fatalCases = map[string]func(){ + "mongo_uri": func() { GetEnvMongoURI() }, + "login_netid": func() { GetEnvLogin() }, + "login_password": func() { + os.Setenv("LOGIN_NETID", "abc123456") + GetEnvLogin() + }, +} + +// TestEnvFatalSubprocess is the entry point for the subprocesses spawned by +// runFatalCase. It does nothing during a normal test run. +func TestEnvFatalSubprocess(t *testing.T) { + + name := os.Getenv(fatalCaseVar) + if name == "" { + t.Skip("not running as a fatal-case subprocess") + } + + fatalCase, ok := fatalCases[name] + if !ok { + t.Fatalf("unknown fatal case %q", name) + } + + fatalCase() +} + +// runFatalCase re-runs this test binary with only TestEnvFatalSubprocess +// enabled, and returns the resulting exit code. +func runFatalCase(t *testing.T, name string) int { + t.Helper() + + executable, err := os.Executable() + if err != nil { + t.Fatalf("could not locate the test binary: %v", err) + } + + cmd := exec.Command(executable, "-test.run", "^TestEnvFatalSubprocess$") + cmd.Env = []string{fatalCaseVar + "=" + name} + + // Run from an empty directory so the subprocess cannot pick up a + // contributor's .env while walking up from the package directory. + cmd.Dir = t.TempDir() + + err = cmd.Run() + + exitError, isExitError := err.(*exec.ExitError) + switch { + case err == nil: + return 0 + case isExitError: + return exitError.ExitCode() + default: + t.Fatalf("could not run the fatal case %q: %v", name, err) + return -1 + } +} + +func TestGetPortString(t *testing.T) { + + t.Run("Unset returns the default port", func(t *testing.T) { + + unsetEnv(t, "PORT") + + if port := GetPortString(); port != ":8080" { + t.Errorf("expected \":8080\" when PORT is unset, got %q", port) + } + }) + + t.Run("Set returns the configured port", func(t *testing.T) { + + t.Setenv("PORT", "3000") + + if port := GetPortString(); port != ":3000" { + t.Errorf("expected \":3000\", got %q", port) + } + }) +} + +func TestGetEnvMongoURI(t *testing.T) { + + t.Run("Set returns the URI", func(t *testing.T) { + + const expected = "mongodb://localhost:27017" + t.Setenv("MONGODB_URI", expected) + + if uri := GetEnvMongoURI(); uri != expected { + t.Errorf("expected %q, got %q", expected, uri) + } + }) + + t.Run("Unset exits", func(t *testing.T) { + + if code := runFatalCase(t, "mongo_uri"); code != 1 { + t.Errorf("expected exit code 1 when MONGODB_URI is unset, got %d", code) + } + }) +} + +func TestGetClubsDBUri(t *testing.T) { - original, hadOriginal := os.LookupEnv("SENTRY_DSN") - defer func() { - if hadOriginal { - os.Setenv("SENTRY_DSN", original) - } else { - os.Unsetenv("SENTRY_DSN") + t.Run("Set returns the URI", func(t *testing.T) { + + const expected = "mongodb://localhost:27017/clubs" + t.Setenv("CLUBS_DB_URI", expected) + + if uri := GetClubsDBUri(); uri != expected { + t.Errorf("expected %q, got %q", expected, uri) } - }() + }) + + t.Run("Unset panics", func(t *testing.T) { + + unsetEnv(t, "CLUBS_DB_URI") + + defer func() { + if recovered := recover(); recovered == nil { + t.Error("expected a panic when CLUBS_DB_URI is unset") + } + }() + + GetClubsDBUri() + }) +} + +func TestGetEnvLogin(t *testing.T) { + + t.Run("Set returns both values", func(t *testing.T) { + + const ( + expectedNetID = "abc123456" + expectedPassword = "hunter2" + ) + t.Setenv("LOGIN_NETID", expectedNetID) + t.Setenv("LOGIN_PASSWORD", expectedPassword) + + netID, password := GetEnvLogin() + + if netID != expectedNetID { + t.Errorf("expected net ID %q, got %q", expectedNetID, netID) + } + if password != expectedPassword { + t.Errorf("expected password %q, got %q", expectedPassword, password) + } + }) + + t.Run("Missing net ID exits", func(t *testing.T) { + + if code := runFatalCase(t, "login_netid"); code != 1 { + t.Errorf("expected exit code 1 when LOGIN_NETID is unset, got %d", code) + } + }) + + t.Run("Missing password exits", func(t *testing.T) { + + if code := runFatalCase(t, "login_password"); code != 1 { + t.Errorf("expected exit code 1 when LOGIN_PASSWORD is unset, got %d", code) + } + }) +} + +func TestGetEnvLimit(t *testing.T) { + + const defaultLimit int64 = 20 + + t.Run("Unset returns the default limit", func(t *testing.T) { + + unsetEnv(t, "LIMIT") + + if limit := GetEnvLimit(); limit != defaultLimit { + t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) + } + }) + + t.Run("Set returns the parsed limit", func(t *testing.T) { + + t.Setenv("LIMIT", "50") + + if limit := GetEnvLimit(); limit != 50 { + t.Errorf("expected 50, got %d", limit) + } + }) + + t.Run("Unparseable falls back to the default limit", func(t *testing.T) { + + t.Setenv("LIMIT", "not-a-number") + + if limit := GetEnvLimit(); limit != defaultLimit { + t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) + } + }) +} + +func TestGetEnvMaxUploadSize(t *testing.T) { + + const ( + defaultLimit int64 = 30 * 1024 * 1024 + hardCapLimit int64 = 50 * 1024 * 1024 + ) + + t.Run("Unset returns the default size", func(t *testing.T) { + + unsetEnv(t, "MAX_UPLOAD_SIZE") + + if size := GetEnvMaxUploadSize(); size != defaultLimit { + t.Errorf("expected the default size %d, got %d", defaultLimit, size) + } + }) + + t.Run("Set returns the parsed size", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "100") + + if size := GetEnvMaxUploadSize(); size != 100 { + t.Errorf("expected 100, got %d", size) + } + }) + + t.Run("Unparseable falls back to the default size", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "not-a-number") + + if size := GetEnvMaxUploadSize(); size != defaultLimit { + t.Errorf("expected the default size %d, got %d", defaultLimit, size) + } + }) + + t.Run("Above the hard cap returns the hard cap", func(t *testing.T) { + + t.Setenv("MAX_UPLOAD_SIZE", "104857600") + + if size := GetEnvMaxUploadSize(); size != hardCapLimit { + t.Errorf("expected the hard cap %d, got %d", hardCapLimit, size) + } + }) +} + +func TestGetEnvSentryDSN(t *testing.T) { t.Run("Unset returns empty string", func(t *testing.T) { - os.Unsetenv("SENTRY_DSN") + unsetEnv(t, "SENTRY_DSN") if dsn := GetEnvSentryDSN(); dsn != "" { t.Errorf("expected an empty DSN when SENTRY_DSN is unset, got %q", dsn) @@ -28,7 +273,7 @@ func TestGetEnvSentryDSN(t *testing.T) { t.Run("Set returns the DSN", func(t *testing.T) { const expected = "https://public@sentry.example.com/1" - os.Setenv("SENTRY_DSN", expected) + t.Setenv("SENTRY_DSN", expected) if dsn := GetEnvSentryDSN(); dsn != expected { t.Errorf("expected %q, got %q", expected, dsn) From a152e733213e86f301c0957b50ff425f902c8a07 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Sat, 19 Sep 2026 20:55:57 -0500 Subject: [PATCH 21/73] codex: address PR review feedback (#436) --- rest/controllers/course_test.go | 75 ++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/rest/controllers/course_test.go b/rest/controllers/course_test.go index fab8f802..969c74c7 100644 --- a/rest/controllers/course_test.go +++ b/rest/controllers/course_test.go @@ -1,27 +1,82 @@ package controllers import ( + "encoding/json" "net/http" "net/http/httptest" "testing" + "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson/primitive" ) -func TestCourseById_InvalidID(t *testing.T) { +func TestCourseById(t *testing.T) { gin.SetMode(gin.TestMode) - // Create a response recorder to capture the result - w := httptest.NewRecorder() - c, _ := gin.CreateTestContext(w) + testCases := []struct { + name string + id string + expectedStatus int + expectedResponseMessage string + expectedData string + }{ + { + name: "ReturnCourseSuccessfully", + id: "6a8f623120b48b6efe790172", + expectedStatus: http.StatusOK, + expectedResponseMessage: "success", + }, + { + name: "InvalidMongoId", + id: "This is invalid MongoDB ID", + expectedStatus: http.StatusBadRequest, + expectedResponseMessage: `Parameter "id" is not a valid ObjectID.`, + }, + { + name: "NoCourseFound", + id: primitive.NewObjectID().Hex(), + expectedStatus: http.StatusNotFound, + expectedResponseMessage: "error", + expectedData: "No courses with given ID", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + responseRecorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(responseRecorder) + context.Request = httptest.NewRequest(http.MethodGet, "/", nil) + context.Params = []gin.Param{{Key: "id", Value: testCase.id}} + + CourseById(context) + + if responseRecorder.Code != testCase.expectedStatus { + t.Fatalf("expected status %d, got %d", testCase.expectedStatus, responseRecorder.Code) + } - // Test sending a completely invalid ID format - c.Params = []gin.Param{{Key: "id", Value: "not-an-object-id"}} + var response schema.APIResponse[json.RawMessage] + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("decode response: %v", err) + } + if response.Status != testCase.expectedStatus { + t.Errorf("expected response status %d, got %d", testCase.expectedStatus, response.Status) + } + if response.Message != testCase.expectedResponseMessage { + t.Errorf("expected response message %q, got %q", testCase.expectedResponseMessage, response.Message) + } - CourseById(c) + if testCase.expectedData == "" { + return + } - // Verify that the controller utility correctly returns a 400 Bad Request - if w.Code != http.StatusBadRequest { - t.Errorf("Expected status 400 for invalid ID, got %d", w.Code) + var responseData string + if err := json.Unmarshal(response.Data, &responseData); err != nil { + t.Fatalf("decode response data: %v", err) + } + if responseData != testCase.expectedData { + t.Errorf("expected response data %q, got %q", testCase.expectedData, responseData) + } + }) } } From 6e8899759a6e58b64fa8f21169ad1a98a1b2af3a Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 21:05:40 -0500 Subject: [PATCH 22/73] test(configs): Move the subprocess const and var to the top of the file --- rest/configs/env_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index c88e2339..c83eb3da 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -6,17 +6,6 @@ import ( "testing" ) -// unsetEnv removes a variable for the duration of the test, restoring whatever -// value it had once the test finishes. -func unsetEnv(t *testing.T, key string) { - t.Helper() - - // t.Setenv records the original value so it is restored on cleanup; the - // unset immediately afterwards is what the test actually wants. - t.Setenv(key, "") - os.Unsetenv(key) -} - // The environment readers below exit through log.Fatalf when a required // variable is missing, which would take the test binary down with them. Each // case is instead run in a subprocess that calls the reader directly, so the @@ -32,6 +21,17 @@ var fatalCases = map[string]func(){ }, } +// unsetEnv removes a variable for the duration of the test, restoring whatever +// value it had once the test finishes. +func unsetEnv(t *testing.T, key string) { + t.Helper() + + // t.Setenv records the original value so it is restored on cleanup; the + // unset immediately afterwards is what the test actually wants. + t.Setenv(key, "") + os.Unsetenv(key) +} + // TestEnvFatalSubprocess is the entry point for the subprocesses spawned by // runFatalCase. It does nothing during a normal test run. func TestEnvFatalSubprocess(t *testing.T) { From d84102d614fa0c94e5459338741088f3da0d0559 Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 19:09:08 -0500 Subject: [PATCH 23/73] fix(configs): Warn on unusable LIMIT and MAX_UPLOAD_SIZE values Both readers fell back to their defaults without saying anything, so a typo in either variable looked identical to leaving it unset. Log the offending value and the default being used instead. GetEnvMaxUploadSize also logs when a value above the hard cap is clamped, since exceeding the cap is a different mistake from an unparseable value. Defaults and return values are unchanged. --- rest/configs/env.go | 3 +++ rest/configs/env_test.go | 51 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/rest/configs/env.go b/rest/configs/env.go index 8fcdc669..60949adc 100644 --- a/rest/configs/env.go +++ b/rest/configs/env.go @@ -87,6 +87,7 @@ func GetEnvLimit() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { + log.Printf("Ignoring 'LIMIT' value %q: not a number, using the default of %d\n", limitString, defaultLimit) return defaultLimit } @@ -106,10 +107,12 @@ func GetEnvMaxUploadSize() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { + log.Printf("Ignoring 'MAX_UPLOAD_SIZE' value %q: not a number, using the default of %d\n", limitString, defaultLimit) return defaultLimit } if limit > hardCapLimit { + log.Printf("Capping 'MAX_UPLOAD_SIZE' of %d to the maximum of %d\n", limit, hardCapLimit) return hardCapLimit } diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index c83eb3da..cf6ebd3f 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -1,8 +1,11 @@ package configs import ( + "bytes" + "log" "os" "os/exec" + "strings" "testing" ) @@ -80,6 +83,26 @@ func runFatalCase(t *testing.T, name string) int { } } +// captureLog redirects the standard logger for the duration of the test and +// returns what was written to it. +func captureLog(t *testing.T) *bytes.Buffer { + t.Helper() + + var captured bytes.Buffer + + originalOutput := log.Writer() + originalFlags := log.Flags() + log.SetOutput(&captured) + log.SetFlags(0) + + t.Cleanup(func() { + log.SetOutput(originalOutput) + log.SetFlags(originalFlags) + }) + + return &captured +} + func TestGetPortString(t *testing.T) { t.Run("Unset returns the default port", func(t *testing.T) { @@ -196,22 +219,32 @@ func TestGetEnvLimit(t *testing.T) { } }) - t.Run("Set returns the parsed limit", func(t *testing.T) { + t.Run("Set returns the parsed limit without warning", func(t *testing.T) { t.Setenv("LIMIT", "50") + captured := captureLog(t) if limit := GetEnvLimit(); limit != 50 { t.Errorf("expected 50, got %d", limit) } + + if logged := captured.String(); logged != "" { + t.Errorf("expected no log output for a valid LIMIT, got %q", logged) + } }) - t.Run("Unparseable falls back to the default limit", func(t *testing.T) { + t.Run("Unparseable falls back to the default limit and warns", func(t *testing.T) { t.Setenv("LIMIT", "not-a-number") + captured := captureLog(t) if limit := GetEnvLimit(); limit != defaultLimit { t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) } + + if logged := captured.String(); !strings.Contains(logged, "LIMIT") { + t.Errorf("expected a warning naming LIMIT, got %q", logged) + } }) } @@ -240,22 +273,32 @@ func TestGetEnvMaxUploadSize(t *testing.T) { } }) - t.Run("Unparseable falls back to the default size", func(t *testing.T) { + t.Run("Unparseable falls back to the default size and warns", func(t *testing.T) { t.Setenv("MAX_UPLOAD_SIZE", "not-a-number") + captured := captureLog(t) if size := GetEnvMaxUploadSize(); size != defaultLimit { t.Errorf("expected the default size %d, got %d", defaultLimit, size) } + + if logged := captured.String(); !strings.Contains(logged, "MAX_UPLOAD_SIZE") { + t.Errorf("expected a warning naming MAX_UPLOAD_SIZE, got %q", logged) + } }) - t.Run("Above the hard cap returns the hard cap", func(t *testing.T) { + t.Run("Above the hard cap returns the hard cap and warns", func(t *testing.T) { t.Setenv("MAX_UPLOAD_SIZE", "104857600") + captured := captureLog(t) if size := GetEnvMaxUploadSize(); size != hardCapLimit { t.Errorf("expected the hard cap %d, got %d", hardCapLimit, size) } + + if logged := captured.String(); !strings.Contains(logged, "MAX_UPLOAD_SIZE") { + t.Errorf("expected a warning naming MAX_UPLOAD_SIZE, got %q", logged) + } }) } From 6421ef9d95caa21baf6f9dc5dca6bce7a2553f7d Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Sat, 19 Sep 2026 21:32:47 -0500 Subject: [PATCH 24/73] feat(api): add degrees endpoint --- rest/controllers/degrees.go | 60 ++++++++++++++++ rest/docs/docs.go | 136 ++++++++++++++++++++++++++++++++++++ rest/docs/swagger.yaml | 93 ++++++++++++++++++++++++ rest/routes/degrees.go | 14 ++++ rest/schema/filter_test.go | 15 ++++ rest/schema/objects.go | 14 ++-- rest/server.go | 1 + 7 files changed, 326 insertions(+), 7 deletions(-) create mode 100644 rest/controllers/degrees.go create mode 100644 rest/routes/degrees.go diff --git a/rest/controllers/degrees.go b/rest/controllers/degrees.go new file mode 100644 index 00000000..c5229d26 --- /dev/null +++ b/rest/controllers/degrees.go @@ -0,0 +1,60 @@ +package controllers + +import ( + "context" + "net/http" + "time" + + "github.com/UTDNebula/nebula-api/rest/configs" + "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/mongo" +) + +var degreesCollection *mongo.Collection = configs.GetCollection("degrees") + +// @Id degrees +// @Router /degrees [get] +// @Tags Degrees +// @Description "Returns paginated academic programs matching the query's string-typed key-value pairs. An areas_of_interest query matches any area in the program's areas_of_interest array." +// @Produce json +// @Param offset query number false "The starting position of the current page of degrees (e.g. For starting at the 17th degree, offset=16)." +// @Param name query string false "The name of the academic program" +// @Param school query string false "The school offering the academic program" +// @Param degree_options.level query string false "The level of one degree option, such as BS or MS" +// @Param degree_options.public_url query string false "The public URL of one degree option" +// @Param degree_options.cip_code query string false "The Classification of Instructional Programs code of one degree option" +// @Param areas_of_interest query string false "One area of interest for the academic program" +// @Success 200 {object} schema.APIResponse[[]schema.AcademicProgram] "A list of academic programs" +// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" +// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" +func Degrees(c *gin.Context) { + ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) + defer cancel() + + query, err := getQuery[schema.AcademicProgram]("Search", c) + if err != nil { + return + } + + optionLimit, err := configs.GetOptionLimit(&query, c) + if err != nil { + respond(c, http.StatusBadRequest, "offset is not type integer", err.Error()) + return + } + + cursor, err := degreesCollection.Find(ctx, query, optionLimit) + if err != nil { + respondWithInternalError(c, err) + return + } + defer cursor.Close(ctx) + + degrees := make([]schema.AcademicProgram, 0) + if err = cursor.All(ctx, °rees); err != nil { + respondWithInternalError(c, err) + return + } + + respond(c, http.StatusOK, "success", degrees) +} diff --git a/rest/docs/docs.go b/rest/docs/docs.go index 0b58bdac..c6351c7e 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -1070,6 +1070,82 @@ const docTemplate = `{ } } }, + "/degrees": { + "get": { + "description": "\"Returns paginated academic programs matching the query's string-typed key-value pairs. An areas_of_interest query matches any area in the program's areas_of_interest array.\"", + "produces": [ + "application/json" + ], + "tags": [ + "Degrees" + ], + "operationId": "degrees", + "parameters": [ + { + "type": "number", + "description": "The starting position of the current page of degrees (e.g. For starting at the 17th degree, offset=16).", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "description": "The name of the academic program", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "The school offering the academic program", + "name": "school", + "in": "query" + }, + { + "type": "string", + "description": "The level of one degree option, such as BS or MS", + "name": "degree_options.level", + "in": "query" + }, + { + "type": "string", + "description": "The public URL of one degree option", + "name": "degree_options.public_url", + "in": "query" + }, + { + "type": "string", + "description": "The Classification of Instructional Programs code of one degree option", + "name": "degree_options.cip_code", + "in": "query" + }, + { + "type": "string", + "description": "One area of interest for the academic program", + "name": "areas_of_interest", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of academic programs", + "schema": { + "$ref": "#/definitions/schema.APIResponse-array_schema_AcademicProgram" + } + }, + "400": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, + "500": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, "/discountPrograms": { "get": { "description": "\"Returns list of discounts filtered using field-specific keyword searches or full-text search.\"", @@ -3495,6 +3571,23 @@ const docTemplate = `{ } } }, + "schema.APIResponse-array_schema_AcademicProgram": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.AcademicProgram" + } + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + } + }, "schema.APIResponse-array_schema_Autocomplete": { "type": "object", "properties": { @@ -3945,6 +4038,29 @@ const docTemplate = `{ } } }, + "schema.AcademicProgram": { + "type": "object", + "properties": { + "areas_of_interest": { + "type": "array", + "items": { + "type": "string" + } + }, + "degree_options": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Degree" + } + }, + "name": { + "type": "string" + }, + "school": { + "type": "string" + } + } + }, "schema.AcademicSession": { "type": "object", "properties": { @@ -4341,6 +4457,26 @@ const docTemplate = `{ } } }, + "schema.Degree": { + "type": "object", + "properties": { + "cip_code": { + "type": "string" + }, + "joint_program": { + "type": "boolean" + }, + "level": { + "type": "string" + }, + "public_url": { + "type": "string" + }, + "stem_designated": { + "type": "boolean" + } + } + }, "schema.DiscountProgram": { "type": "object", "properties": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 66b4b32d..a61c016a 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -10,6 +10,17 @@ definitions: status: type: integer type: object + schema.APIResponse-array_schema_AcademicProgram: + properties: + data: + items: + $ref: '#/definitions/schema.AcademicProgram' + type: array + message: + type: string + status: + type: integer + type: object schema.APIResponse-array_schema_Autocomplete: properties: data: @@ -300,6 +311,21 @@ definitions: status: type: integer type: object + schema.AcademicProgram: + properties: + areas_of_interest: + items: + type: string + type: array + degree_options: + items: + $ref: '#/definitions/schema.Degree' + type: array + name: + type: string + school: + type: string + type: object schema.AcademicSession: properties: end_date: @@ -559,6 +585,19 @@ definitions: title: type: string type: object + schema.Degree: + properties: + cip_code: + type: string + joint_program: + type: boolean + level: + type: string + public_url: + type: string + stem_designated: + type: boolean + type: object schema.DiscountProgram: properties: _id: @@ -1885,6 +1924,60 @@ paths: $ref: '#/definitions/schema.APIResponse-string' tags: - Courses + /degrees: + get: + description: '"Returns paginated academic programs matching the query''s string-typed + key-value pairs. An areas_of_interest query matches any area in the program''s + areas_of_interest array."' + operationId: degrees + parameters: + - description: The starting position of the current page of degrees (e.g. For + starting at the 17th degree, offset=16). + in: query + name: offset + type: number + - description: The name of the academic program + in: query + name: name + type: string + - description: The school offering the academic program + in: query + name: school + type: string + - description: The level of one degree option, such as BS or MS + in: query + name: degree_options.level + type: string + - description: The public URL of one degree option + in: query + name: degree_options.public_url + type: string + - description: The Classification of Instructional Programs code of one degree + option + in: query + name: degree_options.cip_code + type: string + - description: One area of interest for the academic program + in: query + name: areas_of_interest + type: string + produces: + - application/json + responses: + "200": + description: A list of academic programs + schema: + $ref: '#/definitions/schema.APIResponse-array_schema_AcademicProgram' + "400": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' + "500": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Degrees /discountPrograms: get: description: '"Returns list of discounts filtered using field-specific keyword diff --git a/rest/routes/degrees.go b/rest/routes/degrees.go new file mode 100644 index 00000000..17d41050 --- /dev/null +++ b/rest/routes/degrees.go @@ -0,0 +1,14 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func DegreesRoute(router *gin.Engine) { + // All routes related to degrees come here + degreesGroup := router.Group("/degrees") + + degreesGroup.OPTIONS("", controllers.Preflight) + degreesGroup.GET("", controllers.Degrees) +} diff --git a/rest/schema/filter_test.go b/rest/schema/filter_test.go index fbfc21f3..8084ef04 100644 --- a/rest/schema/filter_test.go +++ b/rest/schema/filter_test.go @@ -144,6 +144,21 @@ func TestFilterQuery(t *testing.T) { "nested.number": "0", }, }, + "Academic program": { + Function: FilterQuery[AcademicProgram], + UrlQuery: map[string][]string{ + "name": {"Computer Science"}, + "school": {"Erik Jonsson School of Engineering"}, + "degree_options.level": {"BS"}, + "areas_of_interest": {"computer science"}, + }, + Expected: bson.M{ + "name": "Computer Science", + "school": "Erik Jonsson School of Engineering", + "degree_options.level": "BS", + "areas_of_interest": "computer science", + }, + }, "Multiple values": { Function: FilterQuery[_nested], UrlQuery: map[string][]string{ diff --git a/rest/schema/objects.go b/rest/schema/objects.go index 791681f9..c66534fa 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -350,16 +350,16 @@ type AcademicCalendarDropDeadlines struct { } type AcademicProgram struct { - Title string `bson:"name" json:"name"` - School string `bson:"school" json:"school"` - DegreeOptions []Degree `bson:"degree_options" json:"degree_options"` - AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest"` + Title string `bson:"name" json:"name" queryable:""` + School string `bson:"school" json:"school" queryable:""` + DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` + AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` } type Degree struct { - Level string `bson:"level" json:"level"` - PublicUrl string `bson:"public_url" json:"public_url"` - CipCode string `bson:"cip_code" json:"cip_code"` + Level string `bson:"level" json:"level" queryable:""` + PublicUrl string `bson:"public_url" json:"public_url" queryable:""` + CipCode string `bson:"cip_code" json:"cip_code" queryable:""` StemDesignated bool `bson:"stem_designated" json:"stem_designated"` JointProgram bool `bson:"joint_program" json:"joint_program"` } diff --git a/rest/server.go b/rest/server.go index 565dad66..c259295a 100644 --- a/rest/server.go +++ b/rest/server.go @@ -87,6 +87,7 @@ func main() { routes.AstraRoute(router) routes.MazevoRoute(router) routes.CalendarRoute(router) + routes.DegreesRoute(router) routes.ClubRoute(router) routes.DiscountRoutes(router) routes.EmailRoute(router) From 73bc97c1e977aaca284c8239cf1e3e49dcc2fca0 Mon Sep 17 00:00:00 2001 From: Soham Panda Date: Sat, 19 Sep 2026 21:34:41 -0500 Subject: [PATCH 25/73] fix(configs): Warn once per process instead of once per request GetEnvLimit runs on every paginated request through GetOptionLimit and GetAggregateLimit, and GetEnvMaxUploadSize runs on every upload, so the new warnings would have repeated for the lifetime of a misconfigured process. Guard each one with a sync.Once: a process-wide configuration mistake is worth saying once. The tests now assert the offending value and the fallback appear in the message rather than just the variable name, and cover the once-per- process behavior directly. --- rest/configs/env.go | 22 ++++++++++++++--- rest/configs/env_test.go | 53 +++++++++++++++++++++++++++++++++++----- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/rest/configs/env.go b/rest/configs/env.go index 60949adc..44886d09 100644 --- a/rest/configs/env.go +++ b/rest/configs/env.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "strconv" + "sync" "github.com/joho/godotenv" ) @@ -31,6 +32,15 @@ func init() { } } +// A misconfigured variable is a single, process-wide mistake, but these readers +// run on every request that paginates or uploads. Each warning therefore fires +// at most once per process rather than once per request. +var ( + limitWarnOnce sync.Once + uploadSizeWarnOnce sync.Once + uploadSizeCapWarnOnce sync.Once +) + func GetPortString() string { portNumber, exist := os.LookupEnv("PORT") @@ -87,7 +97,9 @@ func GetEnvLimit() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { - log.Printf("Ignoring 'LIMIT' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + limitWarnOnce.Do(func() { + log.Printf("Ignoring 'LIMIT' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + }) return defaultLimit } @@ -107,12 +119,16 @@ func GetEnvMaxUploadSize() int64 { limit, err := strconv.ParseInt(limitString, 10, 64) if err != nil { - log.Printf("Ignoring 'MAX_UPLOAD_SIZE' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + uploadSizeWarnOnce.Do(func() { + log.Printf("Ignoring 'MAX_UPLOAD_SIZE' value %q: not a number, using the default of %d\n", limitString, defaultLimit) + }) return defaultLimit } if limit > hardCapLimit { - log.Printf("Capping 'MAX_UPLOAD_SIZE' of %d to the maximum of %d\n", limit, hardCapLimit) + uploadSizeCapWarnOnce.Do(func() { + log.Printf("Capping 'MAX_UPLOAD_SIZE' of %d to the maximum of %d\n", limit, hardCapLimit) + }) return hardCapLimit } diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index cf6ebd3f..02a2c5f4 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "strings" + "sync" "testing" ) @@ -103,6 +104,16 @@ func captureLog(t *testing.T) *bytes.Buffer { return &captured } +// resetEnvWarnings clears the once-guards so a test can observe a warning that +// an earlier test has already consumed. +func resetEnvWarnings(t *testing.T) { + t.Helper() + + limitWarnOnce = sync.Once{} + uploadSizeWarnOnce = sync.Once{} + uploadSizeCapWarnOnce = sync.Once{} +} + func TestGetPortString(t *testing.T) { t.Run("Unset returns the default port", func(t *testing.T) { @@ -222,6 +233,7 @@ func TestGetEnvLimit(t *testing.T) { t.Run("Set returns the parsed limit without warning", func(t *testing.T) { t.Setenv("LIMIT", "50") + resetEnvWarnings(t) captured := captureLog(t) if limit := GetEnvLimit(); limit != 50 { @@ -236,14 +248,35 @@ func TestGetEnvLimit(t *testing.T) { t.Run("Unparseable falls back to the default limit and warns", func(t *testing.T) { t.Setenv("LIMIT", "not-a-number") + resetEnvWarnings(t) captured := captureLog(t) if limit := GetEnvLimit(); limit != defaultLimit { t.Errorf("expected the default limit %d, got %d", defaultLimit, limit) } - if logged := captured.String(); !strings.Contains(logged, "LIMIT") { - t.Errorf("expected a warning naming LIMIT, got %q", logged) + logged := captured.String() + for _, want := range []string{"LIMIT", "not-a-number", "20"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } + } + }) + + t.Run("Warns only once per process", func(t *testing.T) { + + t.Setenv("LIMIT", "not-a-number") + resetEnvWarnings(t) + captured := captureLog(t) + + GetEnvLimit() + GetEnvLimit() + GetEnvLimit() + + // GetEnvLimit runs on every paginated request, so a misconfigured + // LIMIT must not log once per request. + if lines := strings.Count(captured.String(), "\n"); lines != 1 { + t.Errorf("expected exactly 1 warning across 3 calls, got %d: %q", lines, captured.String()) } }) } @@ -276,28 +309,36 @@ func TestGetEnvMaxUploadSize(t *testing.T) { t.Run("Unparseable falls back to the default size and warns", func(t *testing.T) { t.Setenv("MAX_UPLOAD_SIZE", "not-a-number") + resetEnvWarnings(t) captured := captureLog(t) if size := GetEnvMaxUploadSize(); size != defaultLimit { t.Errorf("expected the default size %d, got %d", defaultLimit, size) } - if logged := captured.String(); !strings.Contains(logged, "MAX_UPLOAD_SIZE") { - t.Errorf("expected a warning naming MAX_UPLOAD_SIZE, got %q", logged) + logged := captured.String() + for _, want := range []string{"MAX_UPLOAD_SIZE", "not-a-number", "31457280"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } } }) t.Run("Above the hard cap returns the hard cap and warns", func(t *testing.T) { t.Setenv("MAX_UPLOAD_SIZE", "104857600") + resetEnvWarnings(t) captured := captureLog(t) if size := GetEnvMaxUploadSize(); size != hardCapLimit { t.Errorf("expected the hard cap %d, got %d", hardCapLimit, size) } - if logged := captured.String(); !strings.Contains(logged, "MAX_UPLOAD_SIZE") { - t.Errorf("expected a warning naming MAX_UPLOAD_SIZE, got %q", logged) + logged := captured.String() + for _, want := range []string{"MAX_UPLOAD_SIZE", "104857600", "52428800"} { + if !strings.Contains(logged, want) { + t.Errorf("expected the warning to mention %q, got %q", want, logged) + } } }) } From 897f1b0743d47a92344d54b93b12ec41434dfeaa Mon Sep 17 00:00:00 2001 From: Isoscelestial Date: Tue, 22 Sep 2026 11:52:10 -0500 Subject: [PATCH 26/73] feat: update /club/search to use new query instead of deprecated paradedb Co-authored-by: Justin --- rest/controllers/club.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/rest/controllers/club.go b/rest/controllers/club.go index 35fd3bea..7cfd9439 100644 --- a/rest/controllers/club.go +++ b/rest/controllers/club.go @@ -106,7 +106,12 @@ func ClubSearch(c *gin.Context) { 'updated_at', (updated_at AT TIME ZONE 'UTC'), 'officers', officers, 'contacts', contacts - ) ORDER BY paradedb.score(id) DESC) as club + ) ORDER BY ( + (20.0 * word_similarity($1, coalesce(club.alias, ''))) + + (10.0 * word_similarity($1, club.name)) + + (5.0 * word_similarity($1, coalesce(array_to_string(club.tags, ' '), ''))) + + (coalesce(-1.0 * (club.search_tsv <@> to_bm25query(to_tsvector('english', $1), 'club_search_idx')), 0.0)) + ) DESC) as club FROM club JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object( @@ -116,15 +121,16 @@ func ClubSearch(c *gin.Context) { ) as contacts on TRUE JOIN LATERAL ( SELECT jsonb_agg(jsonb_build_object('name',officers.name, 'position',officers.position)) as officers FROM officers where officers.club_id = club.id - ) as officers on TRUE where id @@@ - paradedb.boolean( - should => ARRAY[ - paradedb.boost(20,paradedb.match('alias',$1,distance=>2)), - paradedb.boost(10,paradedb.match('name',$1,distance=>2)), - paradedb.boost(1,paradedb.match('description',$1,distance=>1)), - paradedb.boost(5,paradedb.match('tags',$1,distance=>1)) - ]) and id @@@ - paradedb.const_score(0.0, paradedb.term('approved','approved'::approved_enum)); + ) as officers on TRUE + WHERE ( + club.search_tsv @@ websearch_to_tsquery('english', $1) + OR word_similarity($1, club.name) >= 0.2 + OR word_similarity($1, COALESCE(club.alias, '')) >= 0.2 + OR club.name ILIKE '%' || $1 || '%' + OR club.alias ILIKE '%' || $1 || '%' + ) AND ( + 'approved' = 'approved'::approved_enum + ) `, search).Scan(&raw) if err != nil { From 69c2de1a5ec6c2ce9607a6e4c627ad9dc148417c Mon Sep 17 00:00:00 2001 From: Keven Diaz Date: Tue, 22 Sep 2026 22:11:59 -0500 Subject: [PATCH 27/73] feat(calendar): add academic calendar lookup endpoints (#303) --- rest/controllers/academic_calendars.go | 67 ++++++++++++++++++++++++++ rest/routes/academic_calendars.go | 15 ++++++ rest/server.go | 1 + 3 files changed, 83 insertions(+) create mode 100644 rest/controllers/academic_calendars.go create mode 100644 rest/routes/academic_calendars.go diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go new file mode 100644 index 00000000..d45cc788 --- /dev/null +++ b/rest/controllers/academic_calendars.go @@ -0,0 +1,67 @@ +package controllers + +import ( + "context" + "errors" + "net/http" + "time" + + "github.com/gin-gonic/gin" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + + "github.com/UTDNebula/nebula-api/rest/configs" + + "github.com/UTDNebula/nebula-api/rest/schema" +) + +var academicCalendarsCollection *mongo.Collection = configs.GetCollection("academicCalendars") + +func AcademicCalendarsById(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + //parse string id from id parameter + id := c.Param("id") + query := bson.M{"_id": id} + + //find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No academic calendars with the given ID") + } else { + respondWithInternalError(c, err) + } + return + } + + //return result + respond(c, http.StatusOK, "success", academicCalendar) +} + +func AcadenemicCalendarsCurrent(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + query := bson.M{"timeline": "current"} + + //find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No current academic calendars") + } else { + respondWithInternalError(c, err) + } + return + } + + respond(c, http.StatusOK, "success", academicCalendar) + +} diff --git a/rest/routes/academic_calendars.go b/rest/routes/academic_calendars.go new file mode 100644 index 00000000..bf63a457 --- /dev/null +++ b/rest/routes/academic_calendars.go @@ -0,0 +1,15 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func AcademicCalendarRoute(router *gin.Engine) { + //All routes related to academic calendars route through here + academicCalendarsGroup := router.Group("/academicCalendars") + + academicCalendarsGroup.OPTIONS("", controllers.Preflight) + academicCalendarsGroup.GET(":id", controllers.AcademicCalendarsById) + academicCalendarsGroup.GET("/current", controllers.AcadenemicCalendarsCurrent) +} diff --git a/rest/server.go b/rest/server.go index 565dad66..97976b31 100644 --- a/rest/server.go +++ b/rest/server.go @@ -75,6 +75,7 @@ func main() { router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) // Connect Routes + routes.AcademicCalendarRoute(router) routes.CourseRoute(router) routes.SectionRoute(router) routes.ProfessorRoute(router) From 2337e4fa5ee3f670a971bc4c326495628796be54 Mon Sep 17 00:00:00 2001 From: Keven Diaz Date: Wed, 23 Sep 2026 19:10:45 -0500 Subject: [PATCH 28/73] Update documentation for the new academic calendar endpoints. --- rest/controllers/academic_calendars.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go index d45cc788..a68128b8 100644 --- a/rest/controllers/academic_calendars.go +++ b/rest/controllers/academic_calendars.go @@ -18,17 +18,28 @@ import ( var academicCalendarsCollection *mongo.Collection = configs.GetCollection("academicCalendars") +// AcademicCalendarsById returns an academic calendar by its string ID. +// +// @Id academicCalendarsById +// @Router /academicCalendars/{id} [get] +// @Tags Academic Calendars +// @Description Returns the academic calendar for the given term ID. +// @Produce json +// @Param id path string true "Academic term ID, for example 26F" +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "An academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No matching academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" func AcademicCalendarsById(c *gin.Context) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() var academicCalendar schema.AcademicCalendar - //parse string id from id parameter + // Academic calendar IDs are strings such as "26F", not MongoDB ObjectIDs. id := c.Param("id") query := bson.M{"_id": id} - //find and parse matching academic calendar + // Find and parse matching academic calendar err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) if err != nil { if errors.Is(err, mongo.ErrNoDocuments) { @@ -43,6 +54,16 @@ func AcademicCalendarsById(c *gin.Context) { respond(c, http.StatusOK, "success", academicCalendar) } +// AcademicCalendarsCurrent returns an academic calendar marked as current. +// +// @Id academicCalendarsCurrent +// @Router /academicCalendars/current [get] +// @Tags Academic Calendars +// @Description Returns one academic calendar whose timeline is current. +// @Produce json +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "The current academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No current academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" func AcadenemicCalendarsCurrent(c *gin.Context) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() From a745b2b13ff349cf7c6b1d8e9d6e35d70a6b599d Mon Sep 17 00:00:00 2001 From: Keven Diaz Date: Thu, 24 Sep 2026 09:40:54 -0500 Subject: [PATCH 29/73] Fix typo and add documentation --- rest/controllers/academic_calendars.go | 2 +- rest/docs/docs.go | 204 +++++++++++++++++++++++++ rest/docs/swagger.yaml | 134 ++++++++++++++++ rest/routes/academic_calendars.go | 2 +- 4 files changed, 340 insertions(+), 2 deletions(-) diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go index a68128b8..462b3ab5 100644 --- a/rest/controllers/academic_calendars.go +++ b/rest/controllers/academic_calendars.go @@ -64,7 +64,7 @@ func AcademicCalendarsById(c *gin.Context) { // @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "The current academic calendar" // @Failure 404 {object} schema.APIResponse[string] "No current academic calendar" // @Failure 500 {object} schema.APIResponse[string] "An internal server error" -func AcadenemicCalendarsCurrent(c *gin.Context) { +func AcademicCalendarsCurrent(c *gin.Context) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() diff --git a/rest/docs/docs.go b/rest/docs/docs.go index 0b58bdac..89883eaa 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -15,6 +15,79 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/academicCalendars/current": { + "get": { + "description": "Returns one academic calendar whose timeline is current.", + "produces": [ + "application/json" + ], + "tags": [ + "Academic Calendars" + ], + "operationId": "academicCalendarsCurrent", + "responses": { + "200": { + "description": "The current academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-schema_AcademicCalendar" + } + }, + "404": { + "description": "No current academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, + "500": { + "description": "An internal server error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, + "/academicCalendars/{id}": { + "get": { + "description": "Returns the academic calendar for the given term ID.", + "produces": [ + "application/json" + ], + "tags": [ + "Academic Calendars" + ], + "operationId": "academicCalendarsById", + "parameters": [ + { + "type": "string", + "description": "Academic term ID, for example 26F", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "An academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-schema_AcademicCalendar" + } + }, + "404": { + "description": "No matching academic calendar", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + }, + "500": { + "description": "An internal server error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, "/astra/{date}": { "get": { "description": "\"Returns AstraEvent based on the input date\"", @@ -3679,6 +3752,20 @@ const docTemplate = `{ } } }, + "schema.APIResponse-schema_AcademicCalendar": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/schema.AcademicCalendar" + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + } + }, "schema.APIResponse-schema_BucketInfo": { "type": "object", "properties": { @@ -3945,6 +4032,123 @@ const docTemplate = `{ } } }, + "schema.AcademicCalendar": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "enrollment_opens": { + "type": "string" + }, + "last_from_waitlist": { + "type": "string" + }, + "last_readmission": { + "type": "string" + }, + "midterms_due": { + "type": "string" + }, + "no_classes": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "online_add_swap_ends": { + "type": "string" + }, + "schedule_planner_available": { + "type": "string" + }, + "sessions": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.AcademicCalendarSession" + } + }, + "timeline": { + "type": "string" + }, + "university_closings": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "url": { + "type": "string" + } + } + }, + "schema.AcademicCalendarDropDeadlines": { + "type": "object", + "properties": { + "graduate_withdrawl_ends": { + "type": "string" + }, + "undergrad_approval_required": { + "type": "string" + }, + "without_w": { + "type": "string" + } + } + }, + "schema.AcademicCalendarSession": { + "type": "object", + "properties": { + "begin": { + "type": "string" + }, + "census_day": { + "type": "string" + }, + "drop_deadlines": { + "$ref": "#/definitions/schema.AcademicCalendarDropDeadlines" + }, + "end": { + "type": "string" + }, + "exams": { + "type": "array", + "items": { + "type": "string" + } + }, + "final_grading_period": { + "type": "array", + "items": { + "type": "string" + } + }, + "last_registration": { + "type": "string" + }, + "late_registration": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "reading_days": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "schema.AcademicSession": { "type": "object", "properties": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 66b4b32d..9a34f4d0 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -129,6 +129,15 @@ definitions: status: type: integer type: object + schema.APIResponse-schema_AcademicCalendar: + properties: + data: + $ref: '#/definitions/schema.AcademicCalendar' + message: + type: string + status: + type: integer + type: object schema.APIResponse-schema_BucketInfo: properties: data: @@ -300,6 +309,83 @@ definitions: status: type: integer type: object + schema.AcademicCalendar: + properties: + _id: + type: string + enrollment_opens: + type: string + last_from_waitlist: + type: string + last_readmission: + type: string + midterms_due: + type: string + no_classes: + items: + items: + type: string + type: array + type: array + online_add_swap_ends: + type: string + schedule_planner_available: + type: string + sessions: + items: + $ref: '#/definitions/schema.AcademicCalendarSession' + type: array + timeline: + type: string + university_closings: + items: + items: + type: string + type: array + type: array + url: + type: string + type: object + schema.AcademicCalendarDropDeadlines: + properties: + graduate_withdrawl_ends: + type: string + undergrad_approval_required: + type: string + without_w: + type: string + type: object + schema.AcademicCalendarSession: + properties: + begin: + type: string + census_day: + type: string + drop_deadlines: + $ref: '#/definitions/schema.AcademicCalendarDropDeadlines' + end: + type: string + exams: + items: + type: string + type: array + final_grading_period: + items: + type: string + type: array + last_registration: + type: string + late_registration: + items: + type: string + type: array + name: + type: string + reading_days: + items: + type: string + type: array + type: object schema.AcademicSession: properties: end_date: @@ -1161,6 +1247,54 @@ info: title: dev-nebula-api version: 1.1.0 paths: + /academicCalendars/{id}: + get: + description: Returns the academic calendar for the given term ID. + operationId: academicCalendarsById + parameters: + - description: Academic term ID, for example 26F + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: An academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-schema_AcademicCalendar' + "404": + description: No matching academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-string' + "500": + description: An internal server error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Academic Calendars + /academicCalendars/current: + get: + description: Returns one academic calendar whose timeline is current. + operationId: academicCalendarsCurrent + produces: + - application/json + responses: + "200": + description: The current academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-schema_AcademicCalendar' + "404": + description: No current academic calendar + schema: + $ref: '#/definitions/schema.APIResponse-string' + "500": + description: An internal server error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Academic Calendars /astra/{date}: get: description: '"Returns AstraEvent based on the input date"' diff --git a/rest/routes/academic_calendars.go b/rest/routes/academic_calendars.go index bf63a457..2feeb93a 100644 --- a/rest/routes/academic_calendars.go +++ b/rest/routes/academic_calendars.go @@ -11,5 +11,5 @@ func AcademicCalendarRoute(router *gin.Engine) { academicCalendarsGroup.OPTIONS("", controllers.Preflight) academicCalendarsGroup.GET(":id", controllers.AcademicCalendarsById) - academicCalendarsGroup.GET("/current", controllers.AcadenemicCalendarsCurrent) + academicCalendarsGroup.GET("/current", controllers.AcademicCalendarsCurrent) } From 3945c5590719b5d1ffefdc1bff3e10eb4212235c Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 24 Sep 2026 12:14:50 -0500 Subject: [PATCH 30/73] Use types instead of labels for issues --- .github/ISSUE_TEMPLATE/bug_report_issue_template.yml | 2 +- .github/ISSUE_TEMPLATE/feature_request_issue_template.yml | 2 +- .github/ISSUE_TEMPLATE/internal_issue_template.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml index e276efff..da72b156 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/bug_report_issue_template.yml @@ -1,6 +1,6 @@ name: 🪲 Bug Report description: File a bug report -labels: ["Bug"] +type: Bug body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml index a0b71907..13a15dfe 100644 --- a/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/feature_request_issue_template.yml @@ -1,6 +1,6 @@ name: 💡 Feature Request description: Suggest an idea for this project, e.g., a new feature, an improvement to an existing feature, or a new integration -labels: ["Feature"] +type: Feature body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/internal_issue_template.yml b/.github/ISSUE_TEMPLATE/internal_issue_template.yml index c3c374fc..b8dc0685 100644 --- a/.github/ISSUE_TEMPLATE/internal_issue_template.yml +++ b/.github/ISSUE_TEMPLATE/internal_issue_template.yml @@ -1,6 +1,6 @@ name: 🔧 Internal Change description: Suggest an internal change, e.g., documentation, dependencies, a code refactor -labels: ["Task"] +type: Task body: - type: markdown attributes: From 83d65f8b0f85e004b0d0a59d2b0998c036d89995 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 24 Sep 2026 13:38:51 -0500 Subject: [PATCH 31/73] Fix markdown-lint spacing issues --- docs/Getting-Started.md | 4 ++-- docs/Home.md | 2 +- docs/How-to-Contribute.md | 2 +- docs/Project-Architecture.md | 20 ++++++++++++++++---- docs/Project-Structure.md | 5 +++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/Getting-Started.md b/docs/Getting-Started.md index 5867c679..16ec4612 100644 --- a/docs/Getting-Started.md +++ b/docs/Getting-Started.md @@ -79,7 +79,7 @@ If you installed **Go** with [**Homebrew**](https://brew.sh/), you need to add G ### Configure Environment Variables -First, make a file called `.env` at the root of the project. +First, make a file called `.env` at the root of the project. Then, copy the contents of `.env.template` into it. Some parts in `nebula-api` require certain environment variables, which you can fill in `.env`. @@ -149,4 +149,4 @@ Visit `http://localhost:8080` to access nebula-api locally. ## Next Step -Now that your environment is running, it's time to dive deeper. Check out [Project-Architecture.md](Project-Architecture.md) \ No newline at end of file +Now that your environment is running, it's time to dive deeper. Check out [Project-Architecture.md](Project-Architecture.md) diff --git a/docs/Home.md b/docs/Home.md index 4847cf7b..477ac7ad 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -14,4 +14,4 @@ Join [our community on Discord](https://discord.utdnebula.com) and ask questions Don't edit these docs manually on Github. Instead, suggest a change by [creating an issue](https://github.com/UTDNebula/nebula-api/issues), or [opening a pull request](https://github.com/UTDNebula/nebula-api/pulls) with your changes. -These docs are automatically generated from the `docs/` folder of this repository. \ No newline at end of file +These docs are automatically generated from the `docs/` folder of this repository. diff --git a/docs/How-to-Contribute.md b/docs/How-to-Contribute.md index 0dbd9f10..62ead237 100644 --- a/docs/How-to-Contribute.md +++ b/docs/How-to-Contribute.md @@ -57,4 +57,4 @@ Maintainers will review your PR and may provide suggestions or request changes b ## Next Step -You have everything you need to start, but do feel free to check out other pages first. \ No newline at end of file +You have everything you need to start, but do feel free to check out other pages first. diff --git a/docs/Project-Architecture.md b/docs/Project-Architecture.md index 213debf0..53d9156e 100644 --- a/docs/Project-Architecture.md +++ b/docs/Project-Architecture.md @@ -1,13 +1,17 @@ # API Architecture + Nebula API provides UTD data for others to use, including information on courses, professors, events, and more. ## API Overview + Here's a quick look at Nebula API. ### REST API + The Nebula API is a RESTful API. [What's an API? What does RESTful mean?](https://aws.amazon.com/what-is/restful-api/) Currently, the Nebula API offers information about the following: + - Courses - Professors - Sections @@ -22,11 +26,11 @@ Currently, the Nebula API offers information about the following: > [!NOTE] > Nebula API powers only UTD Trends and UTD Rooms. UTD Clubs and Notebook have their own API internal to their own projects. Specifically, the Clubs endpoints are powered by the internal Clubs database. -All of this information (except for club events) is provided by [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. +All of this information (except for club events) is provided by [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. ### How does Nebula API work? -When a user sends a HTTP request, Gin handles the request by matching the URL request to one of our routes. +When a user sends a HTTP request, Gin handles the request by matching the URL request to one of our routes. Then, Gin passes the request's parameters to the appropriate controller. The controller uses those parameters with Mongo's Go Driver to construct a query filter and execute it against the Mongo database. @@ -34,8 +38,8 @@ The database fetches the requested data and then returns the data back to the co Gin creates a HTTP response with the data and HTTP status code, and finally, Gin sends the HTTP response back to the user. - ### API Diagram + ``` mermaid flowchart LR A[User] --HTTP Request--> B @@ -51,12 +55,15 @@ flowchart LR ``` ## API Documentation + We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes. If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. ## Languages and Core Technologies + ### Golang + [Tour of Go](https://go.dev/tour/welcome/1) - Start here if you're new to Golang. [Effective Go](https://go.dev/doc/effective_go) - Guide for writing clear Golang code. [Go Documentation](https://go.dev/ref/spec) - For more technical details about Golang. @@ -64,6 +71,7 @@ If you make any changes, make sure to run either the Makefile or build.bat to up The main language we use for Nebula API and the API tools. ### MongoDB + [Go Mongo Driver Documentation](https://www.mongodb.com/docs/drivers/go/current/) - For using MongoDB with Golang. Nebula API stores the majority of its data in a MongoDB database. We interact with the Mongo database with the Mongo Go driver. @@ -71,26 +79,30 @@ Nebula API stores the majority of its data in a MongoDB database. We interact wi ## Libraries ### Gin + [Documentation](https://gin-gonic.com/en/docs/) - For more information regarding Gin. Gin is a HTTP web framework for Golang that allows to build the Nebula API. ### Swagger + [Our API Docs](https://api.utdnebula.com/swagger/index.html) - Generated by Swagger. [Documentation](https://swagger.io/docs/) - For more information regarding Swagger. Swagger is responsible for auto-generating our documentation for our API endpoints. ### Sentry + [Documentation](https://docs.sentry.io/get-started/guides/) - Sentry for Golang. Sentry provides performance and error monitoring to help us find and fix problems. ### Google Cloud + [Documentation](https://pkg.go.dev/cloud.google.com/go#section-readme) - Google Cloud Services for Golang. We use Google Cloud for our email and storage endpoints. ## Next Step -See [Project-Structure.md](Project-Structure.md) \ No newline at end of file +See [Project-Structure.md](Project-Structure.md) diff --git a/docs/Project-Structure.md b/docs/Project-Structure.md index caa7bae6..a4f6c097 100644 --- a/docs/Project-Structure.md +++ b/docs/Project-Structure.md @@ -1,4 +1,5 @@ -# Project Structure +# Project Structure + This file provides a brief overview of important directories and files. ```text @@ -27,4 +28,4 @@ nebula-api/ ## Next Step -See [How-to-Contribute.md](How-to-Contribute.md) \ No newline at end of file +See [How-to-Contribute.md](How-to-Contribute.md) From 21c39b544cc4e4afa7b23252481dc6762f28f24c Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 24 Sep 2026 16:44:22 -0500 Subject: [PATCH 32/73] Update Project-architecture --- docs/Project-Architecture.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/Project-Architecture.md b/docs/Project-Architecture.md index 53d9156e..602dc9d7 100644 --- a/docs/Project-Architecture.md +++ b/docs/Project-Architecture.md @@ -10,7 +10,7 @@ Here's a quick look at Nebula API. The Nebula API is a RESTful API. [What's an API? What does RESTful mean?](https://aws.amazon.com/what-is/restful-api/) -Currently, the Nebula API offers information about the following: +Currently, the Nebula API offers data for the following through its endpoints: - Courses - Professors @@ -20,23 +20,29 @@ Currently, the Nebula API offers information about the following: - Mazevo Events - Astra Events - Club Events - provided by UTD Clubs - Rooms +- Rooms - Discounts +Docs for each of these endpoints can be found on [Our REST API Swagger page](https://api.utdnebula.com/swagger/index.html), which is generated from comments in the code. + > [!NOTE] -> Nebula API powers only UTD Trends and UTD Rooms. UTD Clubs and Notebook have their own API internal to their own projects. Specifically, the Clubs endpoints are powered by the internal Clubs database. +> Nebula API powers only UTD Trends and UTD Rooms. UTD Clubs and Notebook have their own API internal to their own projects. In addition, the Clubs endpoints are powered by the internal Clubs database. + +All of this information (except for the clubs endpoints) is gathered with [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. -All of this information (except for club events) is provided by [API tools](https://github.com/UTDNebula/api-tools), which is responsible for scraping, parsing, and uploading the data to a Mongo database. +### How does Nebula REST API work? -### How does Nebula API work? +When a user sends a HTTP request, [Gin](https://gin-gonic.com/) handles the request by matching the URL request to one of our routes. For example, if a user sends a `GET` request to `https://api.utdnebula.com/course`, that request goes to the course route, found in `rest/routes/courses.go`. -When a user sends a HTTP request, Gin handles the request by matching the URL request to one of our routes. +Then, Gin passes the request's arguments to the appropriate controller (in `rest/controllers`). These arguments are used for filtering and limiting data, so the user gets exactly what they want. -Then, Gin passes the request's parameters to the appropriate controller. The controller uses those parameters with Mongo's Go Driver to construct a query filter and execute it against the Mongo database. +The controller uses those arguments with Mongo's Go Driver to construct a query filter and execute it against the Mongo database. This process gets the user the exact data they requested. -The database fetches the requested data and then returns the data back to the controller. The controller sends the data and the outcome of the request, in the form of some HTTP status code, back to Gin. +The Mongo database then fetches the requested data with filters and returns the data back to the controller. The controller sends the data back to Gin. The controller can also provides Gin an HTTP status code indicating the requests outcome (such as if it was successful). -Gin creates a HTTP response with the data and HTTP status code, and finally, Gin sends the HTTP response back to the user. +Gin creates a HTTP response with the data and HTTP status code. + +Finally, Gin sends the HTTP response back to the user. ### API Diagram @@ -56,7 +62,7 @@ flowchart LR ## API Documentation -We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes. +We currently use Swagger for our API documentation. Swagger automatically generates documentation for our API routes from comments in the code. If you make any changes, make sure to run either the Makefile or build.bat to update the documentation. @@ -87,6 +93,7 @@ Gin is a HTTP web framework for Golang that allows to build the Nebula API. ### Swagger [Our API Docs](https://api.utdnebula.com/swagger/index.html) - Generated by Swagger. + [Documentation](https://swagger.io/docs/) - For more information regarding Swagger. Swagger is responsible for auto-generating our documentation for our API endpoints. From fd288b34e8479e00fc04a34d0f621bb0b1d1efd4 Mon Sep 17 00:00:00 2001 From: mikehquan19 Date: Mon, 28 Sep 2026 20:30:41 -0500 Subject: [PATCH 33/73] Remove the email route using task queue --- go.mod | 2 - go.sum | 4 - rest/controllers/academic_calendars.go | 22 +-- rest/controllers/email.go | 147 ------------------- rest/docs/docs.go | 192 ------------------------- rest/docs/swagger.yaml | 130 ----------------- rest/routes/email.go | 122 ---------------- rest/server.go | 1 - 8 files changed, 11 insertions(+), 609 deletions(-) delete mode 100644 rest/controllers/email.go delete mode 100644 rest/routes/email.go diff --git a/go.mod b/go.mod index 8654edf7..cbc7b98f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 - github.com/wneessen/go-mail v0.8.1 go.mongodb.org/mongo-driver v1.17.9 google.golang.org/api v0.293.0 ) @@ -76,7 +75,6 @@ require ( ) require ( - cloud.google.com/go/cloudtasks v1.19.0 github.com/bytedance/gopkg v0.1.4 // indirect github.com/bytedance/sonic v1.15.2 // indirect github.com/gabriel-vasile/mimetype v1.4.15 // indirect diff --git a/go.sum b/go.sum index 70c69e64..50da578a 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,6 @@ cloud.google.com/go/auth v0.23.2 h1:pxSCpfiji41hpzpPdMCftEUCezpgpqmmDdYiAjCKXxo= cloud.google.com/go/auth v0.23.2/go.mod h1:4DhBRcqvtljQN3dJ57qtqbib5ZGCYE5f2crfiiC2EM0= cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= -cloud.google.com/go/cloudtasks v1.19.0 h1:+RK0lPIB6TlcBP7JyqmmhCNihp1Iw4QQ8uxcvlKhBVQ= -cloud.google.com/go/cloudtasks v1.19.0/go.mod h1:8q8wNubq0jFvXW5Pz8P3O7QWJBXOmfrY918FqTgIqHA= cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs= cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10= cloud.google.com/go/iam v1.13.0 h1:ufT3FPT5rFFXu6UtLkNoxaOaV5EuA1dsSkmemCSTo6U= @@ -203,8 +201,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= -github.com/wneessen/go-mail v0.8.1 h1:tVcncj02/QySVFw3zr/kXOzZcuFQqBNT6K+Rbgm/pcM= -github.com/wneessen/go-mail v0.8.1/go.mod h1:dWZ61zadzCIyvB4y1/YzC5O7MrbbzBfPkARmbosdf8w= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.2.0 h1:bYKF2AEwG5rqd1BumT4gAnvwU/M9nBp2pTSxeZw7Wvs= diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go index 462b3ab5..2a897d79 100644 --- a/rest/controllers/academic_calendars.go +++ b/rest/controllers/academic_calendars.go @@ -20,12 +20,12 @@ var academicCalendarsCollection *mongo.Collection = configs.GetCollection("acade // AcademicCalendarsById returns an academic calendar by its string ID. // -// @Id academicCalendarsById -// @Router /academicCalendars/{id} [get] -// @Tags Academic Calendars -// @Description Returns the academic calendar for the given term ID. -// @Produce json -// @Param id path string true "Academic term ID, for example 26F" +// @Id academicCalendarsById +// @Router /academicCalendars/{id} [get] +// @Tags Academic Calendars +// @Description Returns the academic calendar for the given term ID. +// @Produce json +// @Param id path string true "Academic term ID, for example 26F" // @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "An academic calendar" // @Failure 404 {object} schema.APIResponse[string] "No matching academic calendar" // @Failure 500 {object} schema.APIResponse[string] "An internal server error" @@ -56,11 +56,11 @@ func AcademicCalendarsById(c *gin.Context) { // AcademicCalendarsCurrent returns an academic calendar marked as current. // -// @Id academicCalendarsCurrent -// @Router /academicCalendars/current [get] -// @Tags Academic Calendars -// @Description Returns one academic calendar whose timeline is current. -// @Produce json +// @Id academicCalendarsCurrent +// @Router /academicCalendars/current [get] +// @Tags Academic Calendars +// @Description Returns one academic calendar whose timeline is current. +// @Produce json // @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "The current academic calendar" // @Failure 404 {object} schema.APIResponse[string] "No current academic calendar" // @Failure 500 {object} schema.APIResponse[string] "An internal server error" diff --git a/rest/controllers/email.go b/rest/controllers/email.go deleted file mode 100644 index 0a6ed24d..00000000 --- a/rest/controllers/email.go +++ /dev/null @@ -1,147 +0,0 @@ -package controllers - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" - "os" - "time" - - "github.com/UTDNebula/nebula-api/rest/schema" - "github.com/gin-gonic/gin" - "github.com/wneessen/go-mail" - - cloudtasks "cloud.google.com/go/cloudtasks/apiv2" - taskspb "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb" -) - -// @Id sendEmail -// @Router /email/send [post] -// @Tags Internal -// @Description "Send an email via SMTP. This route is restricted to only Nebula Labs internal Projects." -// @Accept json -// @Produce json -// @Param request body schema.EmailRequest true "Email Request Body" -// @Param x-email-send-key header string true "The internal email send key" -// @Success 200 {object} schema.APIResponse[schema.EmailRequest] "Email Request Body" -// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" -// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" -func SendEmail(c *gin.Context) { - ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) - defer cancel() - - var req schema.EmailRequest - - if err := c.ShouldBindJSON(&req); err != nil { - respond(c, http.StatusBadRequest, "invalid request payload", err.Error()) - return - } - - client := c.MustGet("emailClient").(*mail.Client) - smtpUsername := os.Getenv("SMTP_USERNAME") - - m := mail.NewMsg() - if err := m.FromFormat(req.From, smtpUsername); err != nil { - respond(c, http.StatusInternalServerError, "failed to set from address", err.Error()) - return - } - - if err := m.To(req.To...); err != nil { - respond(c, http.StatusBadRequest, "invalid to address(es)", err.Error()) - return - } - - m.Subject(req.Subject) - m.SetBodyString(mail.TypeTextHTML, req.Body) - - for _, att := range req.Attachments { - m.AttachReader(att.Name, bytes.NewReader(att.Data)) - } - - for _, emb := range req.Embeds { - m.EmbedReader(emb.Name, bytes.NewReader(emb.Data), mail.WithFileContentID(emb.Name)) - } - - if err := client.DialAndSendWithContext(ctx, m); err != nil { - respond(c, http.StatusInternalServerError, "failed to send email", err.Error()) - return - } - - respond(c, http.StatusOK, "success", req) -} - -// @Id QueueEmail -// @Router /email/queue [post] -// @Tags Internal -// @Description "Queue an email to be sent via SMTP. Multi-recipient emails will be queued as separate emails to avoid bypassing queueing system. This route is restricted to only Nebula Labs internal Projects." -// @Accept json -// @Produce json -// @Param request body schema.EmailRequest true "Email Request Body" -// @Param x-email-queue-key header string true "The internal email queue key" -// @Success 200 {object} schema.APIResponse[[]string] "The list of queued task names" -// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" -// @Failure 400 {object} schema.APIResponse[string] "A string describing the error" -func QueueEmail(c *gin.Context) { - // Request must be able to bind to email request - var emailReq schema.EmailRequest - if err := c.ShouldBindJSON(&emailReq); err != nil { - respond(c, http.StatusBadRequest, "invalid request payload", err.Error()) - return - } - - client := c.MustGet("tasksClient").(*cloudtasks.Client) - queuePath := os.Getenv("GCLOUD_EMAIL_QUEUE_PATH") - queueUrl := os.Getenv("GCLOUD_EMAIL_QUEUE_URL") - - baseEmailReq := emailReq - baseEmailReq.To = []string{} - - queuedTasks := []string{} - - numOfRecipients := len(emailReq.To) - for i, to := range emailReq.To { - ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) - defer cancel() - - baseEmailReq.To = []string{to} - - body, err := json.Marshal(baseEmailReq) - if err != nil { - respond(c, http.StatusInternalServerError, fmt.Sprintf("failed to serialize email request for recipient %s %d/%d", to, i, numOfRecipients), err.Error()) - return - } - - // Build the Task payload. - // // https://docs.cloud.google.com/tasks/docs/creating-http-target-tasks - taskReq := &taskspb.CreateTaskRequest{ - Parent: queuePath, - Task: &taskspb.Task{ - MessageType: &taskspb.Task_HttpRequest{ - HttpRequest: &taskspb.HttpRequest{ - HttpMethod: taskspb.HttpMethod_POST, - Url: queueUrl, - Headers: map[string]string{ - "x-email-send-key": os.Getenv("EMAIL_SEND_ROUTE_KEY"), // Must get from env bc queue only has x-email-queue-key header - "x-api-key": c.GetHeader("x-api-key"), - }, - }, - }, - }, - } - - // Add a payload message if one is present. - taskReq.Task.GetHttpRequest().Body = []byte(body) - - task, err := client.CreateTask(ctx, taskReq) - if err != nil { - respond(c, http.StatusInternalServerError, fmt.Sprintf("failed to queue email for recipient %s %d/%d", to, i, numOfRecipients), err.Error()) - return - } - - queuedTasks = append(queuedTasks, task.GetName()) - } - - respond(c, http.StatusOK, "success", queuedTasks) -} diff --git a/rest/docs/docs.go b/rest/docs/docs.go index 89883eaa..dd1079f7 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -1207,112 +1207,6 @@ const docTemplate = `{ } } }, - "/email/queue": { - "post": { - "description": "\"Queue an email to be sent via SMTP. Multi-recipient emails will be queued as separate emails to avoid bypassing queueing system. This route is restricted to only Nebula Labs internal Projects.\"", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Internal" - ], - "operationId": "QueueEmail", - "parameters": [ - { - "description": "Email Request Body", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/schema.EmailRequest" - } - }, - { - "type": "string", - "description": "The internal email queue key", - "name": "x-email-queue-key", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "The list of queued task names", - "schema": { - "$ref": "#/definitions/schema.APIResponse-array_string" - } - }, - "400": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } - }, - "500": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } - } - } - } - }, - "/email/send": { - "post": { - "description": "\"Send an email via SMTP. This route is restricted to only Nebula Labs internal Projects.\"", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Internal" - ], - "operationId": "sendEmail", - "parameters": [ - { - "description": "Email Request Body", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/schema.EmailRequest" - } - }, - { - "type": "string", - "description": "The internal email send key", - "name": "x-email-send-key", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "Email Request Body", - "schema": { - "$ref": "#/definitions/schema.APIResponse-schema_EmailRequest" - } - }, - "400": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } - }, - "500": { - "description": "A string describing the error", - "schema": { - "$ref": "#/definitions/schema.APIResponse-string" - } - } - } - } - }, "/events/{date}": { "get": { "description": "\"Returns all sections with meetings on the specified date\"", @@ -3721,23 +3615,6 @@ const docTemplate = `{ } } }, - "schema.APIResponse-array_string": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "string" - } - }, - "message": { - "type": "string" - }, - "status": { - "type": "integer" - } - } - }, "schema.APIResponse-int": { "type": "object", "properties": { @@ -3822,20 +3699,6 @@ const docTemplate = `{ } } }, - "schema.APIResponse-schema_EmailRequest": { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/schema.EmailRequest" - }, - "message": { - "type": "string" - }, - "status": { - "type": "integer" - } - } - }, "schema.APIResponse-schema_MultiBuildingEvents-schema_AstraEvent": { "type": "object", "properties": { @@ -4577,61 +4440,6 @@ const docTemplate = `{ } } }, - "schema.EmailAttachment": { - "type": "object", - "required": [ - "data", - "name" - ], - "properties": { - "data": { - "type": "array", - "items": { - "type": "integer" - } - }, - "name": { - "type": "string" - } - } - }, - "schema.EmailRequest": { - "type": "object", - "required": [ - "body", - "subject", - "to" - ], - "properties": { - "attachments": { - "type": "array", - "items": { - "$ref": "#/definitions/schema.EmailAttachment" - } - }, - "body": { - "type": "string" - }, - "embeds": { - "type": "array", - "items": { - "$ref": "#/definitions/schema.EmailAttachment" - } - }, - "from": { - "type": "string" - }, - "subject": { - "type": "string" - }, - "to": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, "schema.Event": { "type": "object", "properties": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 9a34f4d0..592ee3b9 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -109,17 +109,6 @@ definitions: status: type: integer type: object - schema.APIResponse-array_string: - properties: - data: - items: - type: string - type: array - message: - type: string - status: - type: integer - type: object schema.APIResponse-int: properties: data: @@ -174,15 +163,6 @@ definitions: status: type: integer type: object - schema.APIResponse-schema_EmailRequest: - properties: - data: - $ref: '#/definitions/schema.EmailRequest' - message: - type: string - status: - type: integer - type: object schema.APIResponse-schema_MultiBuildingEvents-schema_AstraEvent: properties: data: @@ -666,43 +646,6 @@ definitions: website: type: string type: object - schema.EmailAttachment: - properties: - data: - items: - type: integer - type: array - name: - type: string - required: - - data - - name - type: object - schema.EmailRequest: - properties: - attachments: - items: - $ref: '#/definitions/schema.EmailAttachment' - type: array - body: - type: string - embeds: - items: - $ref: '#/definitions/schema.EmailAttachment' - type: array - from: - type: string - subject: - type: string - to: - items: - type: string - type: array - required: - - body - - subject - - to - type: object schema.Event: properties: _id: @@ -2062,79 +2005,6 @@ paths: $ref: '#/definitions/schema.APIResponse-string' tags: - Discounts - /email/queue: - post: - consumes: - - application/json - description: '"Queue an email to be sent via SMTP. Multi-recipient emails will - be queued as separate emails to avoid bypassing queueing system. This route - is restricted to only Nebula Labs internal Projects."' - operationId: QueueEmail - parameters: - - description: Email Request Body - in: body - name: request - required: true - schema: - $ref: '#/definitions/schema.EmailRequest' - - description: The internal email queue key - in: header - name: x-email-queue-key - required: true - type: string - produces: - - application/json - responses: - "200": - description: The list of queued task names - schema: - $ref: '#/definitions/schema.APIResponse-array_string' - "400": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - "500": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - tags: - - Internal - /email/send: - post: - consumes: - - application/json - description: '"Send an email via SMTP. This route is restricted to only Nebula - Labs internal Projects."' - operationId: sendEmail - parameters: - - description: Email Request Body - in: body - name: request - required: true - schema: - $ref: '#/definitions/schema.EmailRequest' - - description: The internal email send key - in: header - name: x-email-send-key - required: true - type: string - produces: - - application/json - responses: - "200": - description: Email Request Body - schema: - $ref: '#/definitions/schema.APIResponse-schema_EmailRequest' - "400": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - "500": - description: A string describing the error - schema: - $ref: '#/definitions/schema.APIResponse-string' - tags: - - Internal /events/{date}: get: description: '"Returns all sections with meetings on the specified date"' diff --git a/rest/routes/email.go b/rest/routes/email.go deleted file mode 100644 index bb802e57..00000000 --- a/rest/routes/email.go +++ /dev/null @@ -1,122 +0,0 @@ -package routes - -import ( - "context" - "log" - "net/http" - "os" - "sync" - - cloudtasks "cloud.google.com/go/cloudtasks/apiv2" - "github.com/gin-gonic/gin" - "github.com/wneessen/go-mail" - - "github.com/UTDNebula/nebula-api/rest/controllers" - "github.com/UTDNebula/nebula-api/rest/schema" -) - -var emailClient *mail.Client -var emailClientOnce sync.Once - -var tasksClient *cloudtasks.Client -var tasksClientOnce sync.Once - -func initTasksClient() *cloudtasks.Client { - // Singleton to prevent multiple clients - tasksClientOnce.Do(func() { - - // Checking if env variables are set to know whether or not to skip the route - qPath := os.Getenv("GCLOUD_EMAIL_QUEUE_PATH") - qUrl := os.Getenv("GCLOUD_EMAIL_QUEUE_URL") - - if qPath == "" || qUrl == "" { - log.Println("Cloud Tasks environment variables are not fully configured; skipping email queuing routes") - return - } - - ctx := context.Background() - c, err := cloudtasks.NewClient(ctx) - if err != nil { - log.Printf("Failed to create Cloud Tasks client: %v", err) - return - } - tasksClient = c - }) - return tasksClient -} - -func initEmailClient() *mail.Client { - // Singleton to prevent multiple clients - emailClientOnce.Do(func() { - - // Checking if env variables are set to know whether or not to skip the route - smtpHost := os.Getenv("SMTP_HOST") - smtpUser := os.Getenv("SMTP_USERNAME") - smtpPass := os.Getenv("SMTP_PASSWORD") - sendKey := os.Getenv("EMAIL_SEND_ROUTE_KEY") - - if smtpHost == "" || smtpUser == "" || smtpPass == "" || sendKey == "" { - log.Println("SMTP environment variables are not fully configured; skipping email routes") - return - } - - c, err := mail.NewClient( - smtpHost, - mail.WithTLSPortPolicy(mail.TLSMandatory), - mail.WithSMTPAuth(mail.SMTPAuthAutoDiscover), - mail.WithUsername(smtpUser), - mail.WithPassword(smtpPass), - ) - if err != nil { - log.Printf("Failed to create SMTP client: %v", err) - return - } - emailClient = c - }) - return emailClient -} - -func EmailRoute(router *gin.Engine) { - eClient := initEmailClient() - tClient := initTasksClient() - - if eClient == nil { - log.Println("SMTP client not initialized") - } - - if tClient == nil { - log.Println("Cloud Tasks client not initialized") - } - - if eClient == nil || tClient == nil { - log.Println("skipping email routes") - return - } - - // Restrict with password - authMiddleware := func(key string, envKey string) gin.HandlerFunc { - return func(c *gin.Context) { - secret := c.GetHeader(key) - expected, exist := os.LookupEnv(envKey) - if !exist || secret != expected { - c.AbortWithStatusJSON(http.StatusForbidden, schema.APIResponse[string]{Status: http.StatusForbidden, Message: "error", Data: "Forbidden"}) - return - } - c.Next() - } - } - - // All routes related to email come here - emailGroup := router.Group("/email") - - // Pass to next layer - emailGroup.Use(func(c *gin.Context) { - c.Set("emailClient", eClient) - c.Set("tasksClient", tClient) - c.Next() - }) - - emailGroup.OPTIONS("", controllers.Preflight) - emailGroup.POST("/send", authMiddleware("x-email-send-key", "EMAIL_SEND_ROUTE_KEY"), controllers.SendEmail) - emailGroup.POST("/queue", authMiddleware("x-email-queue-key", "EMAIL_QUEUE_ROUTE_KEY"), controllers.QueueEmail) -} diff --git a/rest/server.go b/rest/server.go index 97976b31..2cbf7ea6 100644 --- a/rest/server.go +++ b/rest/server.go @@ -90,7 +90,6 @@ func main() { routes.CalendarRoute(router) routes.ClubRoute(router) routes.DiscountRoutes(router) - routes.EmailRoute(router) routes.BudgetRoute(router) // Retrieve the port string to serve traffic on From 50384a56b9f77e7e8cbd88b168ae326ecc391e38 Mon Sep 17 00:00:00 2001 From: mikehquan19 Date: Mon, 28 Sep 2026 20:31:15 -0500 Subject: [PATCH 34/73] Move the storage tests over to controllers --- .../{max_upload_size_test.go => controllers/storage_test.go} | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename rest/{max_upload_size_test.go => controllers/storage_test.go} (96%) diff --git a/rest/max_upload_size_test.go b/rest/controllers/storage_test.go similarity index 96% rename from rest/max_upload_size_test.go rename to rest/controllers/storage_test.go index f8b7317e..e10aaf7f 100644 --- a/rest/max_upload_size_test.go +++ b/rest/controllers/storage_test.go @@ -1,4 +1,4 @@ -package main +package controllers import ( "bytes" @@ -10,7 +10,6 @@ import ( "testing" "cloud.google.com/go/storage" - "github.com/UTDNebula/nebula-api/rest/controllers" "github.com/gin-gonic/gin" ) @@ -26,7 +25,7 @@ func TestMaxUploadSize(t *testing.T) { router.POST("/storage/:bucket/:objectID", func(c *gin.Context) { c.Set("gcsClient", &storage.Client{}) - controllers.PostObject(c) + PostObject(c) }) t.Run("Upload within limit", func(t *testing.T) { From 16ab5e5876381622d552de51fe35d9c5412d96ca Mon Sep 17 00:00:00 2001 From: LazyFork Date: Sat, 3 Oct 2026 12:47:19 -0500 Subject: [PATCH 35/73] update imports --- rest/configs/setup.go | 6 +++--- rest/configs/setup_test.go | 2 +- rest/controllers/astra.go | 4 ++-- rest/controllers/autocomplete.go | 4 ++-- rest/controllers/budget.go | 4 ++-- rest/controllers/calendar.go | 4 ++-- rest/controllers/controller_utils.go | 6 +++--- rest/controllers/controllers_utils_test.go | 2 +- rest/controllers/course.go | 4 ++-- rest/controllers/course_test.go | 2 +- rest/controllers/discounts.go | 4 ++-- rest/controllers/events.go | 6 +++--- rest/controllers/grades.go | 6 +++--- rest/controllers/mazevo.go | 4 ++-- rest/controllers/professor.go | 4 ++-- rest/controllers/rooms.go | 4 ++-- rest/controllers/section.go | 4 ++-- rest/controllers/section_test.go | 2 +- rest/controllers/trends.go | 4 ++-- rest/schema/filter.go | 4 ++-- rest/schema/filter_test.go | 2 +- rest/schema/objects.go | 2 +- rest/schema/requirements.go | 4 ++-- 23 files changed, 44 insertions(+), 44 deletions(-) diff --git a/rest/configs/setup.go b/rest/configs/setup.go index 400934a5..d6cfb4a8 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -11,9 +11,9 @@ import ( "github.com/gin-gonic/gin" _ "github.com/jackc/pgx/v5/stdlib" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) type DBSingleton struct { diff --git a/rest/configs/setup_test.go b/rest/configs/setup_test.go index 264edbd8..3c7a172c 100644 --- a/rest/configs/setup_test.go +++ b/rest/configs/setup_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // TestGetOptionLimit checks if the function correctly parses offset from query params diff --git a/rest/controllers/astra.go b/rest/controllers/astra.go index 4c61ce61..40abdf32 100644 --- a/rest/controllers/astra.go +++ b/rest/controllers/astra.go @@ -9,8 +9,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" "github.com/UTDNebula/nebula-api/rest/configs" diff --git a/rest/controllers/autocomplete.go b/rest/controllers/autocomplete.go index 5c9d5f3f..583462eb 100644 --- a/rest/controllers/autocomplete.go +++ b/rest/controllers/autocomplete.go @@ -11,8 +11,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) var DAGCollection *mongo.Collection = configs.GetCollection("DAG") diff --git a/rest/controllers/budget.go b/rest/controllers/budget.go index 9d3b0446..28e4dece 100644 --- a/rest/controllers/budget.go +++ b/rest/controllers/budget.go @@ -8,8 +8,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" "github.com/UTDNebula/nebula-api/rest/configs" diff --git a/rest/controllers/calendar.go b/rest/controllers/calendar.go index d1d051b7..8a88b580 100644 --- a/rest/controllers/calendar.go +++ b/rest/controllers/calendar.go @@ -11,8 +11,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" "github.com/UTDNebula/nebula-api/rest/configs" diff --git a/rest/controllers/controller_utils.go b/rest/controllers/controller_utils.go index cef66d6b..8dd4c919 100644 --- a/rest/controllers/controller_utils.go +++ b/rest/controllers/controller_utils.go @@ -10,9 +10,9 @@ import ( "github.com/getsentry/sentry-go" sentrygin "github.com/getsentry/sentry-go/gin" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" ) // Sets the API's response to a request, producing valid JSON given a status code and data. diff --git a/rest/controllers/controllers_utils_test.go b/rest/controllers/controllers_utils_test.go index a9d1859a..fbb10f21 100644 --- a/rest/controllers/controllers_utils_test.go +++ b/rest/controllers/controllers_utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // TestObjectIDFromParam validates the conversion of URL string parameters to MongoDB ObjectIDs. diff --git a/rest/controllers/course.go b/rest/controllers/course.go index 3765663d..648cca2b 100644 --- a/rest/controllers/course.go +++ b/rest/controllers/course.go @@ -13,8 +13,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) var courseCollection *mongo.Collection = configs.GetCollection("courses") diff --git a/rest/controllers/course_test.go b/rest/controllers/course_test.go index 969c74c7..d4ef792f 100644 --- a/rest/controllers/course_test.go +++ b/rest/controllers/course_test.go @@ -8,7 +8,7 @@ import ( "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) func TestCourseById(t *testing.T) { diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index 2d09b534..e9c504ee 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -12,8 +12,8 @@ import ( "github.com/UTDNebula/nebula-api/rest/configs" "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) var discountCollection *mongo.Collection = configs.GetCollection("discounts") diff --git a/rest/controllers/events.go b/rest/controllers/events.go index 169eefc2..7eca50a1 100644 --- a/rest/controllers/events.go +++ b/rest/controllers/events.go @@ -13,9 +13,9 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" ) var eventsCollection *mongo.Collection = configs.GetCollection("events") diff --git a/rest/controllers/grades.go b/rest/controllers/grades.go index 37c334be..4abf60f4 100644 --- a/rest/controllers/grades.go +++ b/rest/controllers/grades.go @@ -10,9 +10,9 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" ) // We want to Filter (Match) ASAP diff --git a/rest/controllers/mazevo.go b/rest/controllers/mazevo.go index 4f03000b..d22be95b 100644 --- a/rest/controllers/mazevo.go +++ b/rest/controllers/mazevo.go @@ -8,8 +8,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" "github.com/UTDNebula/nebula-api/rest/configs" "github.com/UTDNebula/nebula-api/rest/schema" diff --git a/rest/controllers/professor.go b/rest/controllers/professor.go index 44819bf2..5b614623 100644 --- a/rest/controllers/professor.go +++ b/rest/controllers/professor.go @@ -14,8 +14,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) var professorCollection *mongo.Collection = configs.GetCollection("professors") diff --git a/rest/controllers/rooms.go b/rest/controllers/rooms.go index 6575eea0..c2e28e09 100644 --- a/rest/controllers/rooms.go +++ b/rest/controllers/rooms.go @@ -7,8 +7,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" "github.com/UTDNebula/nebula-api/rest/configs" diff --git a/rest/controllers/section.go b/rest/controllers/section.go index 99fb39de..0d0d9065 100644 --- a/rest/controllers/section.go +++ b/rest/controllers/section.go @@ -12,8 +12,8 @@ import ( "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) var sectionCollection *mongo.Collection = configs.GetCollection("sections") diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go index ac13e90a..7ca35f43 100644 --- a/rest/controllers/section_test.go +++ b/rest/controllers/section_test.go @@ -8,7 +8,7 @@ import ( "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) func TestSectionCourseById(t *testing.T) { diff --git a/rest/controllers/trends.go b/rest/controllers/trends.go index 8a86c2c1..61eed724 100644 --- a/rest/controllers/trends.go +++ b/rest/controllers/trends.go @@ -9,8 +9,8 @@ import ( "github.com/UTDNebula/nebula-api/rest/configs" "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) // @Id trendsCourseSectionSearch diff --git a/rest/schema/filter.go b/rest/schema/filter.go index bfc21b69..4e159179 100644 --- a/rest/schema/filter.go +++ b/rest/schema/filter.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var ( diff --git a/rest/schema/filter_test.go b/rest/schema/filter_test.go index fbfc21f3..d23d46cb 100644 --- a/rest/schema/filter_test.go +++ b/rest/schema/filter_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) type _normal struct { diff --git a/rest/schema/objects.go b/rest/schema/objects.go index 791681f9..af79592a 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -5,7 +5,7 @@ import ( "time" "cloud.google.com/go/storage" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) type Course struct { diff --git a/rest/schema/requirements.go b/rest/schema/requirements.go index 05cdc908..459cfe57 100644 --- a/rest/schema/requirements.go +++ b/rest/schema/requirements.go @@ -3,8 +3,8 @@ package schema import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) type Requirement struct { From c9eb330a97e09ff8a685f72b9d4e12e8b4ea8e08 Mon Sep 17 00:00:00 2001 From: Yoseph Date: Sat, 3 Oct 2026 13:15:18 -0500 Subject: [PATCH 36/73] Import GraphQL rest changes into branch --- go.mod | 5 +- go.sum | 10 +- rest/controllers/controller_utils.go | 5 +- rest/controllers/controllers_utils_test.go | 6 +- rest/controllers/discounts.go | 5 +- rest/controllers/events.go | 3 +- rest/controllers/grades.go | 11 +- rest/schema/filter.go | 5 +- rest/schema/objects.go | 132 ++++++++++----------- rest/schema/requirements.go | 5 +- 10 files changed, 87 insertions(+), 100 deletions(-) diff --git a/go.mod b/go.mod index 8654edf7..fab58772 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 github.com/wneessen/go-mail v0.8.1 - go.mongodb.org/mongo-driver v1.17.9 + go.mongodb.org/mongo-driver/v2 v2.9.1 google.golang.org/api v0.293.0 ) @@ -55,7 +55,6 @@ require ( github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.61.0 // indirect github.com/spiffe/go-spiffe/v2 v2.8.1 // indirect - go.mongodb.org/mongo-driver/v2 v2.8.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect @@ -91,7 +90,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.30.3 // indirect github.com/goccy/go-json v0.10.6 // indirect - github.com/golang/snappy v1.0.0 // indirect github.com/jackc/pgx/v5 v5.10.0 github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.19.2 // indirect @@ -100,7 +98,6 @@ require ( github.com/mattn/go-isatty v0.0.24 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.12.4 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.3.2 // indirect diff --git a/go.sum b/go.sum index 70c69e64..4a12f659 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,6 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= -github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -160,8 +158,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.12.4 h1:amtNRsti20yIhcrkfUJGwoYqBR82jKQFE8SNNYVgGn0= -github.com/montanaflynn/stats v0.12.4/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -214,10 +210,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU= -go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ= -go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= -go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= +go.mongodb.org/mongo-driver/v2 v2.9.1 h1:jewiFs2m1/VOQp8qhFshX6hWZ+EAXDhZHXExAUMcOgQ= +go.mongodb.org/mongo-driver/v2 v2.9.1/go.mod h1:SHKN0IWkKmEVGHLjXnni6s4wPKX4v86FTgOeJJFuXcA= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/detectors/gcp v1.45.0 h1:9jR0ZPRok9ryaOQ2Wx8rg5F7Aon59mxrqbVI60/vlBk= diff --git a/rest/controllers/controller_utils.go b/rest/controllers/controller_utils.go index 8dd4c919..7fb197b7 100644 --- a/rest/controllers/controller_utils.go +++ b/rest/controllers/controller_utils.go @@ -11,7 +11,6 @@ import ( sentrygin "github.com/getsentry/sentry-go/gin" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -69,9 +68,9 @@ func respondWithInternalError(c *gin.Context, err error) { // Attempts to convert the given parameter to an ObjectID for use with MongoDB. // Automatically responds with http.StatusBadRequest if conversion fails. -func objectIDFromParam(c *gin.Context, paramName string) (*primitive.ObjectID, error) { +func objectIDFromParam(c *gin.Context, paramName string) (*bson.ObjectID, error) { idHex := c.Param(paramName) - objectId, convertIdErr := primitive.ObjectIDFromHex(idHex) + objectId, convertIdErr := bson.ObjectIDFromHex(idHex) if convertIdErr != nil { // Respond with an error if we can't covert successfully log.Println(convertIdErr) diff --git a/rest/controllers/controllers_utils_test.go b/rest/controllers/controllers_utils_test.go index fbb10f21..0d3ffb4c 100644 --- a/rest/controllers/controllers_utils_test.go +++ b/rest/controllers/controllers_utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // TestObjectIDFromParam validates the conversion of URL string parameters to MongoDB ObjectIDs. @@ -61,7 +61,7 @@ func TestGetQuery(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) - id := primitive.NewObjectID() + id := bson.NewObjectID() c.Params = []gin.Param{{Key: "id", Value: id.Hex()}} query, err := getQuery[any]("ById", c) @@ -70,7 +70,7 @@ func TestGetQuery(t *testing.T) { t.Errorf("Expected no error, got %v", err) } // Verify the query map contains the correct ObjectID - if *query["_id"].(*primitive.ObjectID) != id { + if *query["_id"].(*bson.ObjectID) != id { t.Errorf("Expected query _id to be %v, got %v", id, query["_id"]) } }) diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index e9c504ee..12501c0b 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -94,12 +94,13 @@ func fetchDiscountCategories() { ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) defer cancel() - results, err := discountCollection.Distinct(ctx, "category", bson.M{}) + var results bson.D + err := discountCollection.Distinct(ctx, "category", bson.M{}).Decode(&results) if err != nil { panic(err) } for _, result := range results { - category, ok := result.(string) + category, ok := result.Value.(string) if !ok { continue // Skip invalid category } diff --git a/rest/controllers/events.go b/rest/controllers/events.go index 7eca50a1..8e45e28d 100644 --- a/rest/controllers/events.go +++ b/rest/controllers/events.go @@ -14,7 +14,6 @@ import ( "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -213,7 +212,7 @@ func SectionsByRoomDetailed(c *gin.Context) { } // Extract section IDs for the specified building and room using case-insensitive matching - var sectionIDs []primitive.ObjectID + var sectionIDs []bson.ObjectID buildingFound := false for _, b := range events.Buildings { if strings.EqualFold(strings.TrimSpace(b.Building), building) { diff --git a/rest/controllers/grades.go b/rest/controllers/grades.go index 4abf60f4..bffbcca8 100644 --- a/rest/controllers/grades.go +++ b/rest/controllers/grades.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -161,7 +160,7 @@ func gradesAggregation(flag string, c *gin.Context) { var sampleCourse schema.Course // the sample course with the given prefix and course number parameter var sampleCourseFind bson.D // the filter using prefix and course number to get sample course - var objId *primitive.ObjectID + var objId *bson.ObjectID var err error @@ -292,9 +291,9 @@ func gradesAggregation(flag string, c *gin.Context) { return } - profIDs := make([]primitive.ObjectID, 0, len(results)) + profIDs := make([]bson.ObjectID, 0, len(results)) for _, prof := range results { - profID := prof["_id"].(primitive.ObjectID) + profID := prof["_id"].(bson.ObjectID) profIDs = append(profIDs, profID) } @@ -317,9 +316,9 @@ func gradesAggregation(flag string, c *gin.Context) { return } - courseIDs := make([]primitive.ObjectID, 0, len(results)) + courseIDs := make([]bson.ObjectID, 0, len(results)) for _, course := range results { - courseID := course["_id"].(primitive.ObjectID) + courseID := course["_id"].(bson.ObjectID) courseIDs = append(courseIDs, courseID) } diff --git a/rest/schema/filter.go b/rest/schema/filter.go index 4e159179..7f1c68a4 100644 --- a/rest/schema/filter.go +++ b/rest/schema/filter.go @@ -9,14 +9,13 @@ import ( "time" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var ( queryableCache sync.Map baseStruct = map[reflect.Type]bool{ - reflect.TypeFor[time.Time](): true, - reflect.TypeFor[primitive.ObjectID](): true, + reflect.TypeFor[time.Time](): true, + reflect.TypeFor[bson.ObjectID](): true, } ignoredParameters = map[string]bool{ "offset": true, diff --git a/rest/schema/objects.go b/rest/schema/objects.go index af79592a..8fd21635 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -5,11 +5,11 @@ import ( "time" "cloud.google.com/go/storage" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type Course struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` Course_number string `bson:"course_number" json:"course_number" queryable:""` Title string `bson:"title" json:"title" queryable:""` @@ -24,7 +24,7 @@ type Course struct { Prerequisites *CollectionRequirement `bson:"prerequisites" json:"prerequisites"` Corequisites *CollectionRequirement `bson:"corequisites" json:"corequisites"` Co_or_pre_requisites *CollectionRequirement `bson:"co_or_pre_requisites" json:"co_or_pre_requisites"` - Sections []primitive.ObjectID `bson:"sections" json:"sections"` + Sections []bson.ObjectID `bson:"sections" json:"sections"` Lecture_contact_hours string `bson:"lecture_contact_hours" json:"lecture_contact_hours" queryable:""` Laboratory_contact_hours string `bson:"laboratory_contact_hours" json:"laboratory_contact_hours" queryable:""` Offering_frequency string `bson:"offering_frequency" json:"offering_frequency" queryable:""` @@ -33,14 +33,14 @@ type Course struct { } type BasicCourse struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` - Course_number string `bson:"course_number" json:"course_number" queryable:""` - Title string `bson:"title" json:"title" queryable:""` - Credit_hours string `bson:"credit_hours" json:"credit_hours" queryable:""` - Class_level string `bson:"class_level" json:"class_level" queryable:""` - Activity_type string `bson:"activity_type" json:"activity_type" queryable:""` - Catalog_year string `bson:"catalog_year" json:"catalog_year" queryable:""` + Id bson.ObjectID `bson:"_id" json:"_id"` + Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` + Course_number string `bson:"course_number" json:"course_number" queryable:""` + Title string `bson:"title" json:"title" queryable:""` + Credit_hours string `bson:"credit_hours" json:"credit_hours" queryable:""` + Class_level string `bson:"class_level" json:"class_level" queryable:""` + Activity_type string `bson:"activity_type" json:"activity_type" queryable:""` + Catalog_year string `bson:"catalog_year" json:"catalog_year" queryable:""` } type AcademicSession struct { @@ -73,12 +73,12 @@ type Meeting struct { } type Section struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` Section_number string `bson:"section_number" json:"section_number" queryable:""` - Course_reference primitive.ObjectID `bson:"course_reference" json:"course_reference" queryable:""` + Course_reference bson.ObjectID `bson:"course_reference" json:"course_reference" queryable:""` Section_corequisites *CollectionRequirement `bson:"section_corequisites" json:"section_corequisites"` Academic_session AcademicSession `bson:"academic_session" json:"academic_session" queryable:""` - Professors []primitive.ObjectID `bson:"professors" json:"professors"` + Professors []bson.ObjectID `bson:"professors" json:"professors"` Teaching_assistants []Assistant `bson:"teaching_assistants" json:"teaching_assistants" queryable:""` Internal_class_number string `bson:"internal_class_number" json:"internal_class_number" queryable:""` Instruction_mode string `bson:"instruction_mode" json:"instruction_mode" queryable:""` @@ -92,48 +92,48 @@ type Section struct { } type Professor struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - First_name string `bson:"first_name" json:"first_name" queryable:""` - Last_name string `bson:"last_name" json:"last_name" queryable:""` - Titles []string `bson:"titles" json:"titles" queryable:""` - Email string `bson:"email" json:"email" queryable:""` - Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` - Office Location `bson:"office" json:"office" queryable:""` - Profile_uri string `bson:"profile_uri" json:"profile_uri" queryable:""` - Image_uri string `bson:"image_uri" json:"image_uri" queryable:""` - Office_hours []Meeting `bson:"office_hours" json:"office_hours" queryable:""` - Sections []primitive.ObjectID `bson:"sections" json:"sections"` + Id bson.ObjectID `bson:"_id" json:"_id"` + First_name string `bson:"first_name" json:"first_name" queryable:""` + Last_name string `bson:"last_name" json:"last_name" queryable:""` + Titles []string `bson:"titles" json:"titles" queryable:""` + Email string `bson:"email" json:"email" queryable:""` + Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` + Office Location `bson:"office" json:"office" queryable:""` + Profile_uri string `bson:"profile_uri" json:"profile_uri" queryable:""` + Image_uri string `bson:"image_uri" json:"image_uri" queryable:""` + Office_hours []Meeting `bson:"office_hours" json:"office_hours" queryable:""` + Sections []bson.ObjectID `bson:"sections" json:"sections"` } type BasicProfessor struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - First_name string `bson:"first_name" json:"first_name" queryable:""` - Last_name string `bson:"last_name" json:"last_name" queryable:""` - Email string `bson:"email" json:"email" queryable:""` - Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` - Office Location `bson:"office" json:"office"` - Office_hours []Meeting `bson:"office_hours" json:"office_hours"` + Id bson.ObjectID `bson:"_id" json:"_id"` + First_name string `bson:"first_name" json:"first_name" queryable:""` + Last_name string `bson:"last_name" json:"last_name" queryable:""` + Email string `bson:"email" json:"email" queryable:""` + Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` + Office Location `bson:"office" json:"office"` + Office_hours []Meeting `bson:"office_hours" json:"office_hours"` } type Organization struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Title string `bson:"title" json:"title"` - Description string `bson:"description" json:"description"` - Categories []string `bson:"categories" json:"categories"` - President_name string `bson:"president_name" json:"president_name"` - Emails []string `bson:"emails" json:"emails"` - Picture_data string `bson:"picture_data" json:"picture_data"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` + Categories []string `bson:"categories" json:"categories"` + President_name string `bson:"president_name" json:"president_name"` + Emails []string `bson:"emails" json:"emails"` + Picture_data string `bson:"picture_data" json:"picture_data"` } type DiscountProgram struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Category string `bson:"category" json:"category"` - Business string `bson:"business" json:"business"` - Address []string `bson:"address" json:"address"` - Phone string `bson:"phone" json:"phone"` - Email string `bson:"email" json:"email"` - Website string `bson:"website" json:"website"` - Discount string `bson:"discount" json:"discount"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Category string `bson:"category" json:"category"` + Business string `bson:"business" json:"business"` + Address []string `bson:"address" json:"address"` + Phone string `bson:"phone" json:"phone"` + Email string `bson:"email" json:"email"` + Website string `bson:"website" json:"website"` + Discount string `bson:"discount" json:"discount"` } type DiscountQueryParams struct { @@ -165,21 +165,21 @@ func (params *DiscountQueryParams) HasFields() bool { } type Event struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Summary string `bson:"summary" json:"summary"` - Location string `bson:"location" json:"location"` - StartTime time.Time `bson:"start_time" json:"start_time"` - EndTime time.Time `bson:"end_time" json:"end_time"` - Description string `bson:"description" json:"description"` - EventType []string `bson:"event_type" json:"event_type"` - TargetAudience []string `bson:"target_audience" json:"target_audience"` - Topic []string `bson:"topic" json:"topic"` - EventTags []string `bson:"event_tags" json:"event_tags"` - EventWebsite string `bson:"event_website" json:"event_website"` - Department []string `bson:"department" json:"department"` - ContactName string `bson:"contact_name" json:"contact_name"` - ContactEmail string `bson:"contact_email" json:"contact_email"` - ContactPhoneNumber string `bson:"contact_phone_number" json:"contact_phone_number"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Summary string `bson:"summary" json:"summary"` + Location string `bson:"location" json:"location"` + StartTime time.Time `bson:"start_time" json:"start_time"` + EndTime time.Time `bson:"end_time" json:"end_time"` + Description string `bson:"description" json:"description"` + EventType []string `bson:"event_type" json:"event_type"` + TargetAudience []string `bson:"target_audience" json:"target_audience"` + Topic []string `bson:"topic" json:"topic"` + EventTags []string `bson:"event_tags" json:"event_tags"` + EventWebsite string `bson:"event_website" json:"event_website"` + Department []string `bson:"department" json:"department"` + ContactName string `bson:"contact_name" json:"contact_name"` + ContactEmail string `bson:"contact_email" json:"contact_email"` + ContactPhoneNumber string `bson:"contact_phone_number" json:"contact_phone_number"` } // Event hierarchy @@ -200,9 +200,9 @@ type RoomEvents[T any] struct { // Event types type SectionWithTime struct { - Section primitive.ObjectID `bson:"section" json:"section"` - StartTime string `bson:"start_time" json:"start_time"` - EndTime string `bson:"end_time" json:"end_time"` + Section bson.ObjectID `bson:"section" json:"section"` + StartTime string `bson:"start_time" json:"start_time"` + EndTime string `bson:"end_time" json:"end_time"` } type AstraEvent struct { @@ -430,7 +430,7 @@ type EvaluationField struct { } type Evaluation struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` CourseExperience []EvaluationField `bson:"course_experience" json:"course_experience"` InstructorExperience []EvaluationField `bson:"instructor_experience" json:"instructor_experience"` StudentExperience []EvaluationField `bson:"student_experience" json:"student_experience"` diff --git a/rest/schema/requirements.go b/rest/schema/requirements.go index 459cfe57..622e047b 100644 --- a/rest/schema/requirements.go +++ b/rest/schema/requirements.go @@ -4,7 +4,6 @@ import ( "fmt" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" ) type Requirement struct { @@ -23,10 +22,10 @@ func NewCourseRequirement(classRef string, minGrade string) *CourseRequirement { type SectionRequirement struct { Requirement `bson:",inline" json:",inline"` - SectionReference primitive.ObjectID `bson:"section_reference" json:"section_reference"` + SectionReference bson.ObjectID `bson:"section_reference" json:"section_reference"` } -func NewSectionRequirement(sectionRef primitive.ObjectID) *SectionRequirement { +func NewSectionRequirement(sectionRef bson.ObjectID) *SectionRequirement { return &SectionRequirement{Requirement{"section"}, sectionRef} } From 0462097869a76aafa8c6cee06023ae15d1c634a2 Mon Sep 17 00:00:00 2001 From: LazyFork Date: Sat, 3 Oct 2026 13:21:59 -0500 Subject: [PATCH 37/73] Import GraphQL rest changes into branch --- go.mod | 5 +- go.sum | 10 +- rest/controllers/controller_utils.go | 5 +- rest/controllers/controllers_utils_test.go | 6 +- rest/controllers/discounts.go | 5 +- rest/controllers/events.go | 3 +- rest/controllers/grades.go | 11 +- rest/schema/filter.go | 5 +- rest/schema/objects.go | 132 ++++++++++----------- rest/schema/requirements.go | 5 +- 10 files changed, 87 insertions(+), 100 deletions(-) diff --git a/go.mod b/go.mod index 8654edf7..fab58772 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 github.com/wneessen/go-mail v0.8.1 - go.mongodb.org/mongo-driver v1.17.9 + go.mongodb.org/mongo-driver/v2 v2.9.1 google.golang.org/api v0.293.0 ) @@ -55,7 +55,6 @@ require ( github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.61.0 // indirect github.com/spiffe/go-spiffe/v2 v2.8.1 // indirect - go.mongodb.org/mongo-driver/v2 v2.8.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect @@ -91,7 +90,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.30.3 // indirect github.com/goccy/go-json v0.10.6 // indirect - github.com/golang/snappy v1.0.0 // indirect github.com/jackc/pgx/v5 v5.10.0 github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.19.2 // indirect @@ -100,7 +98,6 @@ require ( github.com/mattn/go-isatty v0.0.24 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.12.4 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.3.2 // indirect diff --git a/go.sum b/go.sum index 70c69e64..4a12f659 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,6 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= -github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -160,8 +158,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.12.4 h1:amtNRsti20yIhcrkfUJGwoYqBR82jKQFE8SNNYVgGn0= -github.com/montanaflynn/stats v0.12.4/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -214,10 +210,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU= -go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ= -go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= -go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= +go.mongodb.org/mongo-driver/v2 v2.9.1 h1:jewiFs2m1/VOQp8qhFshX6hWZ+EAXDhZHXExAUMcOgQ= +go.mongodb.org/mongo-driver/v2 v2.9.1/go.mod h1:SHKN0IWkKmEVGHLjXnni6s4wPKX4v86FTgOeJJFuXcA= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/detectors/gcp v1.45.0 h1:9jR0ZPRok9ryaOQ2Wx8rg5F7Aon59mxrqbVI60/vlBk= diff --git a/rest/controllers/controller_utils.go b/rest/controllers/controller_utils.go index 8dd4c919..7fb197b7 100644 --- a/rest/controllers/controller_utils.go +++ b/rest/controllers/controller_utils.go @@ -11,7 +11,6 @@ import ( sentrygin "github.com/getsentry/sentry-go/gin" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -69,9 +68,9 @@ func respondWithInternalError(c *gin.Context, err error) { // Attempts to convert the given parameter to an ObjectID for use with MongoDB. // Automatically responds with http.StatusBadRequest if conversion fails. -func objectIDFromParam(c *gin.Context, paramName string) (*primitive.ObjectID, error) { +func objectIDFromParam(c *gin.Context, paramName string) (*bson.ObjectID, error) { idHex := c.Param(paramName) - objectId, convertIdErr := primitive.ObjectIDFromHex(idHex) + objectId, convertIdErr := bson.ObjectIDFromHex(idHex) if convertIdErr != nil { // Respond with an error if we can't covert successfully log.Println(convertIdErr) diff --git a/rest/controllers/controllers_utils_test.go b/rest/controllers/controllers_utils_test.go index fbb10f21..0d3ffb4c 100644 --- a/rest/controllers/controllers_utils_test.go +++ b/rest/controllers/controllers_utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) // TestObjectIDFromParam validates the conversion of URL string parameters to MongoDB ObjectIDs. @@ -61,7 +61,7 @@ func TestGetQuery(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) - id := primitive.NewObjectID() + id := bson.NewObjectID() c.Params = []gin.Param{{Key: "id", Value: id.Hex()}} query, err := getQuery[any]("ById", c) @@ -70,7 +70,7 @@ func TestGetQuery(t *testing.T) { t.Errorf("Expected no error, got %v", err) } // Verify the query map contains the correct ObjectID - if *query["_id"].(*primitive.ObjectID) != id { + if *query["_id"].(*bson.ObjectID) != id { t.Errorf("Expected query _id to be %v, got %v", id, query["_id"]) } }) diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index e9c504ee..12501c0b 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -94,12 +94,13 @@ func fetchDiscountCategories() { ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) defer cancel() - results, err := discountCollection.Distinct(ctx, "category", bson.M{}) + var results bson.D + err := discountCollection.Distinct(ctx, "category", bson.M{}).Decode(&results) if err != nil { panic(err) } for _, result := range results { - category, ok := result.(string) + category, ok := result.Value.(string) if !ok { continue // Skip invalid category } diff --git a/rest/controllers/events.go b/rest/controllers/events.go index 7eca50a1..8e45e28d 100644 --- a/rest/controllers/events.go +++ b/rest/controllers/events.go @@ -14,7 +14,6 @@ import ( "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -213,7 +212,7 @@ func SectionsByRoomDetailed(c *gin.Context) { } // Extract section IDs for the specified building and room using case-insensitive matching - var sectionIDs []primitive.ObjectID + var sectionIDs []bson.ObjectID buildingFound := false for _, b := range events.Buildings { if strings.EqualFold(strings.TrimSpace(b.Building), building) { diff --git a/rest/controllers/grades.go b/rest/controllers/grades.go index 4abf60f4..bffbcca8 100644 --- a/rest/controllers/grades.go +++ b/rest/controllers/grades.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" "go.mongodb.org/mongo-driver/v2/mongo" ) @@ -161,7 +160,7 @@ func gradesAggregation(flag string, c *gin.Context) { var sampleCourse schema.Course // the sample course with the given prefix and course number parameter var sampleCourseFind bson.D // the filter using prefix and course number to get sample course - var objId *primitive.ObjectID + var objId *bson.ObjectID var err error @@ -292,9 +291,9 @@ func gradesAggregation(flag string, c *gin.Context) { return } - profIDs := make([]primitive.ObjectID, 0, len(results)) + profIDs := make([]bson.ObjectID, 0, len(results)) for _, prof := range results { - profID := prof["_id"].(primitive.ObjectID) + profID := prof["_id"].(bson.ObjectID) profIDs = append(profIDs, profID) } @@ -317,9 +316,9 @@ func gradesAggregation(flag string, c *gin.Context) { return } - courseIDs := make([]primitive.ObjectID, 0, len(results)) + courseIDs := make([]bson.ObjectID, 0, len(results)) for _, course := range results { - courseID := course["_id"].(primitive.ObjectID) + courseID := course["_id"].(bson.ObjectID) courseIDs = append(courseIDs, courseID) } diff --git a/rest/schema/filter.go b/rest/schema/filter.go index 4e159179..7f1c68a4 100644 --- a/rest/schema/filter.go +++ b/rest/schema/filter.go @@ -9,14 +9,13 @@ import ( "time" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var ( queryableCache sync.Map baseStruct = map[reflect.Type]bool{ - reflect.TypeFor[time.Time](): true, - reflect.TypeFor[primitive.ObjectID](): true, + reflect.TypeFor[time.Time](): true, + reflect.TypeFor[bson.ObjectID](): true, } ignoredParameters = map[string]bool{ "offset": true, diff --git a/rest/schema/objects.go b/rest/schema/objects.go index af79592a..8fd21635 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -5,11 +5,11 @@ import ( "time" "cloud.google.com/go/storage" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) type Course struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` Course_number string `bson:"course_number" json:"course_number" queryable:""` Title string `bson:"title" json:"title" queryable:""` @@ -24,7 +24,7 @@ type Course struct { Prerequisites *CollectionRequirement `bson:"prerequisites" json:"prerequisites"` Corequisites *CollectionRequirement `bson:"corequisites" json:"corequisites"` Co_or_pre_requisites *CollectionRequirement `bson:"co_or_pre_requisites" json:"co_or_pre_requisites"` - Sections []primitive.ObjectID `bson:"sections" json:"sections"` + Sections []bson.ObjectID `bson:"sections" json:"sections"` Lecture_contact_hours string `bson:"lecture_contact_hours" json:"lecture_contact_hours" queryable:""` Laboratory_contact_hours string `bson:"laboratory_contact_hours" json:"laboratory_contact_hours" queryable:""` Offering_frequency string `bson:"offering_frequency" json:"offering_frequency" queryable:""` @@ -33,14 +33,14 @@ type Course struct { } type BasicCourse struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` - Course_number string `bson:"course_number" json:"course_number" queryable:""` - Title string `bson:"title" json:"title" queryable:""` - Credit_hours string `bson:"credit_hours" json:"credit_hours" queryable:""` - Class_level string `bson:"class_level" json:"class_level" queryable:""` - Activity_type string `bson:"activity_type" json:"activity_type" queryable:""` - Catalog_year string `bson:"catalog_year" json:"catalog_year" queryable:""` + Id bson.ObjectID `bson:"_id" json:"_id"` + Subject_prefix string `bson:"subject_prefix" json:"subject_prefix" queryable:""` + Course_number string `bson:"course_number" json:"course_number" queryable:""` + Title string `bson:"title" json:"title" queryable:""` + Credit_hours string `bson:"credit_hours" json:"credit_hours" queryable:""` + Class_level string `bson:"class_level" json:"class_level" queryable:""` + Activity_type string `bson:"activity_type" json:"activity_type" queryable:""` + Catalog_year string `bson:"catalog_year" json:"catalog_year" queryable:""` } type AcademicSession struct { @@ -73,12 +73,12 @@ type Meeting struct { } type Section struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` Section_number string `bson:"section_number" json:"section_number" queryable:""` - Course_reference primitive.ObjectID `bson:"course_reference" json:"course_reference" queryable:""` + Course_reference bson.ObjectID `bson:"course_reference" json:"course_reference" queryable:""` Section_corequisites *CollectionRequirement `bson:"section_corequisites" json:"section_corequisites"` Academic_session AcademicSession `bson:"academic_session" json:"academic_session" queryable:""` - Professors []primitive.ObjectID `bson:"professors" json:"professors"` + Professors []bson.ObjectID `bson:"professors" json:"professors"` Teaching_assistants []Assistant `bson:"teaching_assistants" json:"teaching_assistants" queryable:""` Internal_class_number string `bson:"internal_class_number" json:"internal_class_number" queryable:""` Instruction_mode string `bson:"instruction_mode" json:"instruction_mode" queryable:""` @@ -92,48 +92,48 @@ type Section struct { } type Professor struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - First_name string `bson:"first_name" json:"first_name" queryable:""` - Last_name string `bson:"last_name" json:"last_name" queryable:""` - Titles []string `bson:"titles" json:"titles" queryable:""` - Email string `bson:"email" json:"email" queryable:""` - Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` - Office Location `bson:"office" json:"office" queryable:""` - Profile_uri string `bson:"profile_uri" json:"profile_uri" queryable:""` - Image_uri string `bson:"image_uri" json:"image_uri" queryable:""` - Office_hours []Meeting `bson:"office_hours" json:"office_hours" queryable:""` - Sections []primitive.ObjectID `bson:"sections" json:"sections"` + Id bson.ObjectID `bson:"_id" json:"_id"` + First_name string `bson:"first_name" json:"first_name" queryable:""` + Last_name string `bson:"last_name" json:"last_name" queryable:""` + Titles []string `bson:"titles" json:"titles" queryable:""` + Email string `bson:"email" json:"email" queryable:""` + Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` + Office Location `bson:"office" json:"office" queryable:""` + Profile_uri string `bson:"profile_uri" json:"profile_uri" queryable:""` + Image_uri string `bson:"image_uri" json:"image_uri" queryable:""` + Office_hours []Meeting `bson:"office_hours" json:"office_hours" queryable:""` + Sections []bson.ObjectID `bson:"sections" json:"sections"` } type BasicProfessor struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - First_name string `bson:"first_name" json:"first_name" queryable:""` - Last_name string `bson:"last_name" json:"last_name" queryable:""` - Email string `bson:"email" json:"email" queryable:""` - Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` - Office Location `bson:"office" json:"office"` - Office_hours []Meeting `bson:"office_hours" json:"office_hours"` + Id bson.ObjectID `bson:"_id" json:"_id"` + First_name string `bson:"first_name" json:"first_name" queryable:""` + Last_name string `bson:"last_name" json:"last_name" queryable:""` + Email string `bson:"email" json:"email" queryable:""` + Phone_number string `bson:"phone_number" json:"phone_number" queryable:""` + Office Location `bson:"office" json:"office"` + Office_hours []Meeting `bson:"office_hours" json:"office_hours"` } type Organization struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Title string `bson:"title" json:"title"` - Description string `bson:"description" json:"description"` - Categories []string `bson:"categories" json:"categories"` - President_name string `bson:"president_name" json:"president_name"` - Emails []string `bson:"emails" json:"emails"` - Picture_data string `bson:"picture_data" json:"picture_data"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` + Categories []string `bson:"categories" json:"categories"` + President_name string `bson:"president_name" json:"president_name"` + Emails []string `bson:"emails" json:"emails"` + Picture_data string `bson:"picture_data" json:"picture_data"` } type DiscountProgram struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Category string `bson:"category" json:"category"` - Business string `bson:"business" json:"business"` - Address []string `bson:"address" json:"address"` - Phone string `bson:"phone" json:"phone"` - Email string `bson:"email" json:"email"` - Website string `bson:"website" json:"website"` - Discount string `bson:"discount" json:"discount"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Category string `bson:"category" json:"category"` + Business string `bson:"business" json:"business"` + Address []string `bson:"address" json:"address"` + Phone string `bson:"phone" json:"phone"` + Email string `bson:"email" json:"email"` + Website string `bson:"website" json:"website"` + Discount string `bson:"discount" json:"discount"` } type DiscountQueryParams struct { @@ -165,21 +165,21 @@ func (params *DiscountQueryParams) HasFields() bool { } type Event struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` - Summary string `bson:"summary" json:"summary"` - Location string `bson:"location" json:"location"` - StartTime time.Time `bson:"start_time" json:"start_time"` - EndTime time.Time `bson:"end_time" json:"end_time"` - Description string `bson:"description" json:"description"` - EventType []string `bson:"event_type" json:"event_type"` - TargetAudience []string `bson:"target_audience" json:"target_audience"` - Topic []string `bson:"topic" json:"topic"` - EventTags []string `bson:"event_tags" json:"event_tags"` - EventWebsite string `bson:"event_website" json:"event_website"` - Department []string `bson:"department" json:"department"` - ContactName string `bson:"contact_name" json:"contact_name"` - ContactEmail string `bson:"contact_email" json:"contact_email"` - ContactPhoneNumber string `bson:"contact_phone_number" json:"contact_phone_number"` + Id bson.ObjectID `bson:"_id" json:"_id"` + Summary string `bson:"summary" json:"summary"` + Location string `bson:"location" json:"location"` + StartTime time.Time `bson:"start_time" json:"start_time"` + EndTime time.Time `bson:"end_time" json:"end_time"` + Description string `bson:"description" json:"description"` + EventType []string `bson:"event_type" json:"event_type"` + TargetAudience []string `bson:"target_audience" json:"target_audience"` + Topic []string `bson:"topic" json:"topic"` + EventTags []string `bson:"event_tags" json:"event_tags"` + EventWebsite string `bson:"event_website" json:"event_website"` + Department []string `bson:"department" json:"department"` + ContactName string `bson:"contact_name" json:"contact_name"` + ContactEmail string `bson:"contact_email" json:"contact_email"` + ContactPhoneNumber string `bson:"contact_phone_number" json:"contact_phone_number"` } // Event hierarchy @@ -200,9 +200,9 @@ type RoomEvents[T any] struct { // Event types type SectionWithTime struct { - Section primitive.ObjectID `bson:"section" json:"section"` - StartTime string `bson:"start_time" json:"start_time"` - EndTime string `bson:"end_time" json:"end_time"` + Section bson.ObjectID `bson:"section" json:"section"` + StartTime string `bson:"start_time" json:"start_time"` + EndTime string `bson:"end_time" json:"end_time"` } type AstraEvent struct { @@ -430,7 +430,7 @@ type EvaluationField struct { } type Evaluation struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` CourseExperience []EvaluationField `bson:"course_experience" json:"course_experience"` InstructorExperience []EvaluationField `bson:"instructor_experience" json:"instructor_experience"` StudentExperience []EvaluationField `bson:"student_experience" json:"student_experience"` diff --git a/rest/schema/requirements.go b/rest/schema/requirements.go index 459cfe57..622e047b 100644 --- a/rest/schema/requirements.go +++ b/rest/schema/requirements.go @@ -4,7 +4,6 @@ import ( "fmt" "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/bson/primitive" ) type Requirement struct { @@ -23,10 +22,10 @@ func NewCourseRequirement(classRef string, minGrade string) *CourseRequirement { type SectionRequirement struct { Requirement `bson:",inline" json:",inline"` - SectionReference primitive.ObjectID `bson:"section_reference" json:"section_reference"` + SectionReference bson.ObjectID `bson:"section_reference" json:"section_reference"` } -func NewSectionRequirement(sectionRef primitive.ObjectID) *SectionRequirement { +func NewSectionRequirement(sectionRef bson.ObjectID) *SectionRequirement { return &SectionRequirement{Requirement{"section"}, sectionRef} } From 4cf91b8068833a27611570d7ad8a8dcf636dea5f Mon Sep 17 00:00:00 2001 From: LazyFork Date: Sat, 3 Oct 2026 15:07:15 -0500 Subject: [PATCH 38/73] fix files in configs/ --- rest/configs/setup.go | 6 +++--- rest/configs/setup_test.go | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/rest/configs/setup.go b/rest/configs/setup.go index d6cfb4a8..1273bcef 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -27,7 +27,7 @@ func ConnectDB() *mongo.Client { once.Do(func() { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(GetEnvMongoURI())) + client, err := mongo.Connect(options.Client().ApplyURI(GetEnvMongoURI())) if err != nil { log.Fatalf("Unable to create MongoDB client") } @@ -59,7 +59,7 @@ func GetCollection(collectionName string) *mongo.Collection { // Returns *options.FindOptions with a limit and offset applied. // Produces an error if user-provided offset isn't able to be parsed. -func GetOptionLimit(query *bson.M, c *gin.Context) (*options.FindOptions, error) { +func GetOptionLimit(query *bson.M, c *gin.Context) (*options.FindOptionsBuilder, error) { delete(*query, "offset") // removes offset (if present) in query --offset is not field in collections // parses offset if included in the query @@ -73,7 +73,7 @@ func GetOptionLimit(query *bson.M, c *gin.Context) (*options.FindOptions, error) } else { offset, err = strconv.ParseInt(c.Query("offset"), 10, 64) if err != nil { - return options.Find().SetSkip(0).SetLimit(limit), err // default value for offset + return options.Find().SetSkip(0).SetLimit(limit), err } } diff --git a/rest/configs/setup_test.go b/rest/configs/setup_test.go index 3c7a172c..2e1cbbbd 100644 --- a/rest/configs/setup_test.go +++ b/rest/configs/setup_test.go @@ -6,6 +6,7 @@ import ( "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // TestGetOptionLimit checks if the function correctly parses offset from query params @@ -18,19 +19,28 @@ func TestGetOptionLimit(t *testing.T) { c.Request = httptest.NewRequest("GET", "/?offset=25", nil) query := bson.M{"offset": "should-be-deleted"} - options, err := GetOptionLimit(&query, c) + + optBuilder, err := GetOptionLimit(&query, c) if err != nil { - t.Fatalf("Expected no error, got %v", err) // Use Fatalf to stop if options is nil + t.Fatalf("Expected no error, got %v", err) } if _, exists := query["offset"]; exists { t.Error("Expected 'offset' to be deleted from the query map") } - // Ensure we compare the same types (int64) - if options.Skip == nil || *options.Skip != int64(25) { - t.Errorf("Expected Skip to be 25, got %v", options.Skip) + // Extract the builder data into a testable struct + // opt acts as a setter + findOpts := &options.FindOptions{} + for _, opt := range optBuilder.Opts { + if err := opt(findOpts); err != nil { + t.Fatal(err) + } + } + + if findOpts.Skip == nil || *findOpts.Skip != int64(25) { + t.Errorf("Expected Skip to be 25, got %v", findOpts.Skip) } }) @@ -39,10 +49,20 @@ func TestGetOptionLimit(t *testing.T) { c.Request = httptest.NewRequest("GET", "/", nil) query := bson.M{} - options, _ := GetOptionLimit(&query, c) - if options.Skip == nil || *options.Skip != int64(0) { - t.Errorf("Expected default Skip to be 0, got %v", options.Skip) + optBuilder, _ := GetOptionLimit(&query, c) + + // Extract the builder data into a testable struct + // opt acts as a setter + findOpts := &options.FindOptions{} + for _, opt := range optBuilder.Opts { + if err := opt(findOpts); err != nil { + t.Fatal(err) + } + } + + if findOpts.Skip == nil || *findOpts.Skip != int64(0) { + t.Errorf("Expected default Skip to be 0, got %v", findOpts.Skip) } }) From 52d91e01bff2ca6badc9b439415c7f6d6e874bd4 Mon Sep 17 00:00:00 2001 From: LazyFork Date: Sat, 3 Oct 2026 15:07:25 -0500 Subject: [PATCH 39/73] fix tests in controllers --- rest/controllers/course_test.go | 4 ++-- rest/controllers/section_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rest/controllers/course_test.go b/rest/controllers/course_test.go index d4ef792f..b6adff09 100644 --- a/rest/controllers/course_test.go +++ b/rest/controllers/course_test.go @@ -8,7 +8,7 @@ import ( "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) func TestCourseById(t *testing.T) { @@ -35,7 +35,7 @@ func TestCourseById(t *testing.T) { }, { name: "NoCourseFound", - id: primitive.NewObjectID().Hex(), + id: bson.NewObjectID().Hex(), expectedStatus: http.StatusNotFound, expectedResponseMessage: "error", expectedData: "No courses with given ID", diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go index 7ca35f43..b921a8da 100644 --- a/rest/controllers/section_test.go +++ b/rest/controllers/section_test.go @@ -8,7 +8,7 @@ import ( "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" ) func TestSectionCourseById(t *testing.T) { @@ -35,7 +35,7 @@ func TestSectionCourseById(t *testing.T) { }, { name: "NoSectionFound", - id: primitive.NewObjectID().Hex(), + id: bson.NewObjectID().Hex(), expectedStatus: http.StatusNotFound, expectedResponseMessage: "error", expectedData: "No section with given ID", From 0a610183957b887fbc6dd86fa3a0e07c1f6e5c8b Mon Sep 17 00:00:00 2001 From: LazyFork Date: Sat, 3 Oct 2026 23:59:48 -0500 Subject: [PATCH 40/73] `academic-calendars.go` added back --- rest/controllers/academic_calendars.go | 87 ++++++++++++++++++++++++++ rest/routes/academic_calendars.go | 15 +++++ 2 files changed, 102 insertions(+) create mode 100644 rest/controllers/academic_calendars.go create mode 100644 rest/routes/academic_calendars.go diff --git a/rest/controllers/academic_calendars.go b/rest/controllers/academic_calendars.go new file mode 100644 index 00000000..530c7401 --- /dev/null +++ b/rest/controllers/academic_calendars.go @@ -0,0 +1,87 @@ +package controllers + +import ( + "context" + "errors" + "net/http" + "time" + + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + + "github.com/UTDNebula/nebula-api/rest/configs" + + "github.com/UTDNebula/nebula-api/rest/schema" +) + +var academicCalendarsCollection *mongo.Collection = configs.GetCollection("academicCalendars") + +// AcademicCalendarsById returns an academic calendar by its string ID. +// +// @Id academicCalendarsById +// @Router /academicCalendars/{id} [get] +// @Tags Academic Calendars +// @Description Returns the academic calendar for the given term ID. +// @Produce json +// @Param id path string true "Academic term ID, for example 26F" +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "An academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No matching academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" +func AcademicCalendarsById(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + // Academic calendar IDs are strings such as "26F", not MongoDB ObjectIDs. + id := c.Param("id") + query := bson.M{"_id": id} + + // Find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No academic calendars with the given ID") + } else { + respondWithInternalError(c, err) + } + return + } + + //return result + respond(c, http.StatusOK, "success", academicCalendar) +} + +// AcademicCalendarsCurrent returns an academic calendar marked as current. +// +// @Id academicCalendarsCurrent +// @Router /academicCalendars/current [get] +// @Tags Academic Calendars +// @Description Returns one academic calendar whose timeline is current. +// @Produce json +// @Success 200 {object} schema.APIResponse[schema.AcademicCalendar] "The current academic calendar" +// @Failure 404 {object} schema.APIResponse[string] "No current academic calendar" +// @Failure 500 {object} schema.APIResponse[string] "An internal server error" +func AcademicCalendarsCurrent(c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var academicCalendar schema.AcademicCalendar + + query := bson.M{"timeline": "current"} + + //find and parse matching academic calendar + err := academicCalendarsCollection.FindOne(ctx, query).Decode(&academicCalendar) + if err != nil { + if errors.Is(err, mongo.ErrNoDocuments) { + respond(c, http.StatusNotFound, "error", "No current academic calendars") + } else { + respondWithInternalError(c, err) + } + return + } + + respond(c, http.StatusOK, "success", academicCalendar) + +} diff --git a/rest/routes/academic_calendars.go b/rest/routes/academic_calendars.go new file mode 100644 index 00000000..2feeb93a --- /dev/null +++ b/rest/routes/academic_calendars.go @@ -0,0 +1,15 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func AcademicCalendarRoute(router *gin.Engine) { + //All routes related to academic calendars route through here + academicCalendarsGroup := router.Group("/academicCalendars") + + academicCalendarsGroup.OPTIONS("", controllers.Preflight) + academicCalendarsGroup.GET(":id", controllers.AcademicCalendarsById) + academicCalendarsGroup.GET("/current", controllers.AcademicCalendarsCurrent) +} From 1c3379fc3f069b81d00bc17dc7971d451c826176 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Thu, 1 Oct 2026 18:53:12 -0500 Subject: [PATCH 41/73] Get discount endpoint working --- rest/controllers/discounts.go | 11 ++--------- rest/routes/discounts.go | 1 + 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index 12501c0b..5c423073 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -94,18 +94,11 @@ func fetchDiscountCategories() { ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second) defer cancel() - var results bson.D - err := discountCollection.Distinct(ctx, "category", bson.M{}).Decode(&results) + err := discountCollection.Distinct(ctx, "category", bson.M{}).Decode(&discountCategories) if err != nil { panic(err) } - for _, result := range results { - category, ok := result.Value.(string) - if !ok { - continue // Skip invalid category - } - discountCategories = append(discountCategories, category) - } + log.Printf("Available categories: %s.\n", discountCategories) }) } diff --git a/rest/routes/discounts.go b/rest/routes/discounts.go index b8ff9fd9..ead48e82 100644 --- a/rest/routes/discounts.go +++ b/rest/routes/discounts.go @@ -9,5 +9,6 @@ func DiscountRoutes(router *gin.Engine) { // All routes related to discounts come here discountGroup := router.Group("/discountPrograms") + discountGroup.OPTIONS("", controllers.Preflight) discountGroup.GET("", controllers.DiscountSearch) } From c4d2b1d22699e4c7161dc29ae7ec4382dce5be17 Mon Sep 17 00:00:00 2001 From: Chris Torres Date: Wed, 7 Oct 2026 23:00:38 -0500 Subject: [PATCH 42/73] Make CLUBS_DB_URI optional in configuration and routing Skip Clubs DB initialization and club route registration when CLUBS_DB_URI is unavailable. --- rest/configs/env.go | 2 +- rest/configs/setup.go | 16 +++++++++++----- rest/routes/club.go | 13 ++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/rest/configs/env.go b/rest/configs/env.go index 8fcdc669..56aba96d 100644 --- a/rest/configs/env.go +++ b/rest/configs/env.go @@ -56,7 +56,7 @@ func GetEnvMongoURI() string { func GetClubsDBUri() string { uri, exist := os.LookupEnv("CLUBS_DB_URI") if !exist { - log.Panic("Error loading 'CLUBS_DB_URI' from the .env file") + log.Println("Error loading 'CLUBS_DB_URI' from the .env file") } return uri diff --git a/rest/configs/setup.go b/rest/configs/setup.go index 400934a5..8b05d7e4 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -116,21 +116,27 @@ var clubOnce sync.Once func ConnectClubsDB() *sql.DB { clubOnce.Do(func() { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + // Skip Clubs DB initialization when the optional CLUBS_DB_URI is not configured. + uri := GetClubsDBUri() + if uri == "" { + log.Println("No CLUBS_DB_URI provided in env file. Skipping Clubs DB connection.") + return + } - db, err := sql.Open("pgx", GetClubsDBUri()) + db, err := sql.Open("pgx", uri) if err != nil { log.Panic("Unable to connect to clubs database.") } - defer cancel() - // ping the database err = db.PingContext(ctx) if err != nil { - log.Panic("Unable to ping database") + log.Panic("Unable to ping database.") } - log.Printf("Connected to Clubs DB") + log.Println("Connected to Clubs DB.") clubsDbInstance = db }) diff --git a/rest/routes/club.go b/rest/routes/club.go index 48b1b40f..f800bb9c 100644 --- a/rest/routes/club.go +++ b/rest/routes/club.go @@ -1,12 +1,23 @@ package routes import ( + "log" + + "github.com/UTDNebula/nebula-api/rest/configs" "github.com/UTDNebula/nebula-api/rest/controllers" "github.com/gin-gonic/gin" ) func ClubRoute(router *gin.Engine) { - // All routes related to courses come here + db := configs.ConnectClubsDB() + + // Skip accessing Clubs DB if CLUBS_DB_URI is not provided. + if db == nil { + log.Println("Skipping club routes.") + return + } + + // All routes related to clubs come here. clubGroup := router.Group("/club") clubGroup.OPTIONS("", controllers.Preflight) From 5decfeeb54ef3f989433368c012b62be7baac128 Mon Sep 17 00:00:00 2001 From: Ashwin Avadhanula Date: Mon, 26 Oct 2026 18:32:34 -0500 Subject: [PATCH 43/73] fixed #401 Fixed all the linting errors 17 errcheck 2 govet 4 staticcheck Updated Makefile + build.bat with corresponding setup line and golangci-lint run ./... --- .github/.DS_Store | Bin 0 -> 8196 bytes Makefile | 2 ++ build.bat | 4 +++ rest/configs/env_test.go | 9 +++-- rest/configs/setup.go | 3 +- rest/controllers/club.go | 5 ++- rest/controllers/controller_utils.go | 2 +- rest/controllers/course.go | 6 ++-- rest/controllers/discounts.go | 2 +- rest/controllers/events.go | 2 +- rest/controllers/storage_test.go | 17 +++++++--- rest/controllers/trends.go | 2 +- rest/schema/filter.go | 5 +-- rest/schema/requirements.go | 48 ++++++++++++++++++++------- rest/server.go | 8 +++-- 15 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 .github/.DS_Store diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..69e118f1340192f0956359c14d906fb920310544 GIT binary patch literal 8196 zcmeHMU2GIp6u#fIzzh>%sFW6D*tILPQiw|h{6S&c-9`#6Ew;7W<)`fK40OVDrtHja zsYX+u{6S58(Wt0zMtwkymZ(oAO4P*oK#(XeVoZGE#Xo#7F`hejwooXKDv`O#z2Dq> z&$)N++3%a1v&$GmN7>lGSR-Rhrpi%MshOkjd0ww7QaDmW2=Zs_AhVgvCYWb?S6N2` zQ3Rq0L=lK05Je!0!1WLTy0dwauW|2-*{F>o5JljIi~xT>#Hn&jg*YWJcy&+{qyU7q zG#nIqraU0-3e(ie*j=6+JgZ=v!+Ec0I)>#O8l12Ue>7(q zrsG=&EwiL3OR#Rh$&Z<5>Kd1?xMiiT3!6(m)m5_Pf_0>9`IA~gmc<@=Q$mro>AeOW zvd1;}ibgP_>rKtFyoZmcOD45qSk+tCkwbpKqa%kOGr2)gG;iRr<%F*4rp>aV8H0Ad zVA^6e_1-Nsv~#E;P8<%_Z5MFEU+m`_cjrC7ciePlK2mzSEa$w@ ze97#caLiKGqg$4PuaU;NOQ&J^ZYhYyt|na{=1a93hH22DS2QlK)BE*7SvyTWn&nh1 zpU6O84nf(I6IIeBQftLy;uA|e1TjvelA^b?Y8WEF5_Fbi9c%~N&&Js#JH}pMud@%> zG&{*ov9H-#cAovjerCV0U)e?WCu*?}OR*BG(To<{jyBwhjo6Gdy3vDO$e{=WCJwknF+Rm-IEBw~7T@DMe!vC%j*Iw1QlvU* zrKC%%q-Lo_S}V0mTcvH%c4@bilSZUbaRMp4tJuETCzB?rKey<{h3KRcbBiwa!1k^k zJG-x2(S5gw%k1W*^~)OKtJmJK@$UQEXUHhHTczveG6(QM0bta64U0Ba74E?wmzmwq*u{R#@bY^hSaD8 zzMEp}RSmM}+@o$$wOZ1p=x$Y4sTxy6rz4h$Xf>TwblEa literal 0 HcmV?d00001 diff --git a/Makefile b/Makefile index 0768072b..7c89141c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ setup: go install honnef.co/go/tools/cmd/staticcheck@latest go install golang.org/x/tools/cmd/goimports@latest go install github.com/swaggo/swag/cmd/swag@latest + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 check: go mod tidy @@ -20,6 +21,7 @@ check: staticcheck ./... gofmt -w . goimports -w . + golangci-lint run ./... test: go test ./... -count=1 diff --git a/build.bat b/build.bat index 5249a1b7..3ffe5dcb 100644 --- a/build.bat +++ b/build.bat @@ -40,6 +40,8 @@ go install golang.org/x/tools/cmd/goimports@latest if ERRORLEVEL 1 exit /b %ERRORLEVEL% go install github.com/swaggo/swag/cmd/swag@latest if ERRORLEVEL 1 exit /b %ERRORLEVEL% +go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 +if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo Setup done! echo. exit /b 0 @@ -66,6 +68,8 @@ gofmt -w . if ERRORLEVEL 1 exit /b %ERRORLEVEL% goimports -w . if ERRORLEVEL 1 exit /b %ERRORLEVEL% +golangci-lint run ./... +if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo Checks done! echo. exit /b 0 diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index 02a2c5f4..9254c82a 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -20,7 +20,9 @@ var fatalCases = map[string]func(){ "mongo_uri": func() { GetEnvMongoURI() }, "login_netid": func() { GetEnvLogin() }, "login_password": func() { - os.Setenv("LOGIN_NETID", "abc123456") + if err := os.Setenv("LOGIN_NETID", "abc123456"); err != nil { + log.Fatalf("Error setting 'LOGIN_NETID'") + } GetEnvLogin() }, } @@ -33,7 +35,10 @@ func unsetEnv(t *testing.T, key string) { // t.Setenv records the original value so it is restored on cleanup; the // unset immediately afterwards is what the test actually wants. t.Setenv(key, "") - os.Unsetenv(key) + if err := os.Unsetenv(key); err != nil { + t.Fatalf("Error unsetting key") + } + } // TestEnvFatalSubprocess is the entry point for the subprocesses spawned by diff --git a/rest/configs/setup.go b/rest/configs/setup.go index 400934a5..0bd0fb46 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -66,7 +66,7 @@ func GetOptionLimit(query *bson.M, c *gin.Context) (*options.FindOptions, error) var offset int64 var err error - var limit int64 = GetEnvLimit() + var limit = GetEnvLimit() if c.Query("offset") == "" { offset = 0 // default value for offset @@ -128,6 +128,7 @@ func ConnectClubsDB() *sql.DB { err = db.PingContext(ctx) if err != nil { log.Panic("Unable to ping database") + return } log.Printf("Connected to Clubs DB") diff --git a/rest/controllers/club.go b/rest/controllers/club.go index 7cfd9439..ba11b02e 100644 --- a/rest/controllers/club.go +++ b/rest/controllers/club.go @@ -2,7 +2,6 @@ package controllers import ( "context" - "database/sql" "net/http" "time" @@ -26,7 +25,7 @@ func ClubDirectoryInfo(c *gin.Context) { ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) defer cancel() - var clubsDatabase *sql.DB = configs.ConnectClubsDB() + var clubsDatabase = configs.ConnectClubsDB() id := c.Param("id") var raw []byte @@ -90,7 +89,7 @@ func ClubSearch(c *gin.Context) { ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) defer cancel() - var clubsDatabase *sql.DB = configs.ConnectClubsDB() + var clubsDatabase = configs.ConnectClubsDB() search := c.Query("q") var raw []byte diff --git a/rest/controllers/controller_utils.go b/rest/controllers/controller_utils.go index cef66d6b..d5c4669d 100644 --- a/rest/controllers/controller_utils.go +++ b/rest/controllers/controller_utils.go @@ -57,7 +57,7 @@ func getQuery[T any](flag string, c *gin.Context) (bson.M, error) { func respondWithInternalError(c *gin.Context, err error) { // Note that we use log.Output here to be able to set the stack depth to the frame above this one (2), // which allows us to log the location this function was called from - log.Output(2, fmt.Sprintf("INTERNAL SERVER ERROR: %s", err.Error())) + _ = log.Output(2, fmt.Sprintf("INTERNAL SERVER ERROR: %s", err.Error())) // Capture error with Sentry if hub := sentrygin.GetHubFromContext(c); hub != nil { hub.WithScope(func(scope *sentry.Scope) { diff --git a/rest/controllers/course.go b/rest/controllers/course.go index 3765663d..3f1fb783 100644 --- a/rest/controllers/course.go +++ b/rest/controllers/course.go @@ -64,7 +64,7 @@ func CourseSearch(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // Retrieve and parse all valid documents if err = cursor.All(ctx, &courses); err != nil { @@ -129,7 +129,7 @@ func CourseAll(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // retrieve and parse all valid documents if err = cursor.All(ctx, &courses); err != nil { @@ -262,7 +262,7 @@ func courseAggregate[T any](flag string, c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err = cursor.All(ctx, &queryResults); err != nil { respondWithInternalError(c, err) diff --git a/rest/controllers/discounts.go b/rest/controllers/discounts.go index 2d09b534..82f9f843 100644 --- a/rest/controllers/discounts.go +++ b/rest/controllers/discounts.go @@ -76,7 +76,7 @@ func DiscountSearch(c *gin.Context) { return } } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() discounts := make([]schema.DiscountProgram, 0) if err = cursor.All(ctx, &discounts); err != nil { diff --git a/rest/controllers/events.go b/rest/controllers/events.go index 169eefc2..3a40f7f1 100644 --- a/rest/controllers/events.go +++ b/rest/controllers/events.go @@ -247,7 +247,7 @@ func SectionsByRoomDetailed(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err = cursor.All(ctx, §ionsByRoom.Events); err != nil { respondWithInternalError(c, err) diff --git a/rest/controllers/storage_test.go b/rest/controllers/storage_test.go index e10aaf7f..b87a44bb 100644 --- a/rest/controllers/storage_test.go +++ b/rest/controllers/storage_test.go @@ -15,8 +15,15 @@ import ( func TestMaxUploadSize(t *testing.T) { // Set the environment variable for max upload size (e.g., 100 bytes) - os.Setenv("MAX_UPLOAD_SIZE", "100") - defer os.Unsetenv("MAX_UPLOAD_SIZE") + if err := os.Setenv("MAX_UPLOAD_SIZE", "100"); err != nil { + t.Fatalf("Error setting 'MAX_UPLOAD_SIZE'") + } + + defer func() { + if err := os.Unsetenv("MAX_UPLOAD_SIZE"); err != nil { + t.Fatalf("Error unsetting 'MAX_UPLOAD_SIZE'") + } + }() // Setup Gin gin.SetMode(gin.TestMode) @@ -32,7 +39,7 @@ func TestMaxUploadSize(t *testing.T) { defer func() { if r := recover(); r != nil { - + t.Fatalf("Recover panicked unexpectedly") } }() @@ -67,8 +74,8 @@ func TestMaxUploadSize(t *testing.T) { t.Run("Upload exceeding limit via Stream", func(t *testing.T) { pr, pw := io.Pipe() go func() { - pw.Write(make([]byte, 150)) - pw.Close() + _, _ = pw.Write(make([]byte, 150)) + _ = pw.Close() }() req, _ := http.NewRequest("POST", "/storage/test-bucket/stream-file", pr) diff --git a/rest/controllers/trends.go b/rest/controllers/trends.go index 8a86c2c1..35124415 100644 --- a/rest/controllers/trends.go +++ b/rest/controllers/trends.go @@ -101,7 +101,7 @@ func trendsSectionSearch(flag string, c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() if err := cursor.All(ctx, &detailedSections); err != nil { respondWithInternalError(c, err) diff --git a/rest/schema/filter.go b/rest/schema/filter.go index bfc21b69..971f7eed 100644 --- a/rest/schema/filter.go +++ b/rest/schema/filter.go @@ -142,7 +142,8 @@ func recBuild(t reflect.Type, prefix string, queryableMap map[string]bool, visit // Pointer types are allowed to recur once, i.e., only considered a loop when // the same pointer type appears twice in a row. func willCreateLoop(visited []reflect.Type, value reflect.Type) bool { - if value.Kind() != reflect.Ptr { + if value.Kind() != + reflect.Pointer { return false } @@ -156,7 +157,7 @@ func willCreateLoop(visited []reflect.Type, value reflect.Type) bool { // drillType gets the base of a type, removing pointers and slices/arrays func drillType(t reflect.Type) reflect.Type { - for t.Kind() == reflect.Ptr || t.Kind() == reflect.Slice || t.Kind() == reflect.Array { + for t.Kind() == reflect.Pointer || t.Kind() == reflect.Slice || t.Kind() == reflect.Array { t = t.Elem() } return t diff --git a/rest/schema/requirements.go b/rest/schema/requirements.go index 05cdc908..7d88f2a1 100644 --- a/rest/schema/requirements.go +++ b/rest/schema/requirements.go @@ -114,51 +114,75 @@ func (cr *CollectionRequirement) UnmarshalBSON(data []byte) error { switch optionType { case "course": var t CourseRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "section": var t SectionRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "major": var t MajorRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "minor": var t MinorRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "gpa": var t GPARequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "consent": var t ConsentRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "collection": var t CollectionRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "hours": var t HoursRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "other": var t OtherRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "choice": var t ChoiceRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "limit": var t LimitRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) case "core": var t CoreRequirement - bson.Unmarshal(bytes, &t) + if err := bson.Unmarshal(bytes, &t); err != nil { + return err + } out = append(out, t) default: return fmt.Errorf("unknown option type: %v", err) diff --git a/rest/server.go b/rest/server.go index 2cbf7ea6..d1b5ebbd 100644 --- a/rest/server.go +++ b/rest/server.go @@ -60,7 +60,9 @@ func main() { // Configure Gin Router router := gin.New() // Get rid of "trusted all proxies" warning -- we don't care - router.SetTrustedProxies(nil) + if err := router.SetTrustedProxies(nil); err != nil { + return + } // Enable CORS router.Use(CORS) @@ -96,7 +98,9 @@ func main() { portString := configs.GetPortString() // Serve Traffic - router.Run(portString) + if err := router.Run(portString); err != nil { + return + } } func CORS(c *gin.Context) { From a51b154f09e72a07ac4433f45dfff51427fc4d56 Mon Sep 17 00:00:00 2001 From: Ashwin Avadhanula Date: Wed, 28 Oct 2026 08:27:05 -0500 Subject: [PATCH 44/73] Update .gitignore added **/.DS_Store for mac --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ded428b1..a38b48d4 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,7 @@ go.work go.work.sum # API executables -rest-api \ No newline at end of file +rest-api + +# mac +**/.DS_Store \ No newline at end of file From 3a176dbd8764cb6ca49b5d34d496618514e71d32 Mon Sep 17 00:00:00 2001 From: Krish Date: Wed, 28 Oct 2026 18:38:25 -0500 Subject: [PATCH 45/73] fix: redirect root route to Swagger UI --- rest/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rest/server.go b/rest/server.go index 2cbf7ea6..abe851a5 100644 --- a/rest/server.go +++ b/rest/server.go @@ -2,6 +2,7 @@ package main import ( "log" + "net/http" "github.com/UTDNebula/nebula-api/rest/configs" _ "github.com/UTDNebula/nebula-api/rest/docs" @@ -74,6 +75,11 @@ func main() { // Setup swagger-ui hosted router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + // Redirect users to swagger documentation + router.GET("/", func(r *gin.Context) { + r.Redirect(http.StatusFound, "/swagger/index.html") + }) + // Connect Routes routes.AcademicCalendarRoute(router) routes.CourseRoute(router) From 4142e91015f4e0684af1e401d71af0151f2c94bf Mon Sep 17 00:00:00 2001 From: ThatRell Date: Thu, 29 Oct 2026 11:36:25 -0500 Subject: [PATCH 46/73] created /semesters endpoint that returns list of terms --- rest/controllers/semesters.go | 62 +++++++++++++++++++++++++++++++++++ rest/routes/semesters.go | 13 ++++++++ rest/server.go | 1 + semesters-data.json | 1 + 4 files changed, 77 insertions(+) create mode 100644 rest/controllers/semesters.go create mode 100644 rest/routes/semesters.go create mode 100644 semesters-data.json diff --git a/rest/controllers/semesters.go b/rest/controllers/semesters.go new file mode 100644 index 00000000..f25c308e --- /dev/null +++ b/rest/controllers/semesters.go @@ -0,0 +1,62 @@ +package controllers + +import ( + "encoding/json" + "net/http" + "os" + + "github.com/gin-gonic/gin" +) + +const testfilename = "semesters-data.json" + +func Semesters(c *gin.Context) { + terms := []string{ + "26u", + "26s", + "26f", + "25u", + "25s", + "25f", + "24u", + "24s", + "24f", + "23u", + "23s", + "23f", + "22u", + "22s", + "22f", + "21u", + "21s", + "21f", + "20u", + "20s", + "20f", + "19u", + "19s", + "19f", + "18u", + "18s", + } + + jsonData, err := json.Marshal(terms) + if err != nil { + respondWithInternalError(c, err) + return + } + + err = os.WriteFile(testfilename, jsonData, 0644) + if err != nil { + respondWithInternalError(c, err) + return + } + + fileBytes, err := os.ReadFile(testfilename) + if err != nil { + respondWithInternalError(c, err) + return + } + + respond(c, http.StatusOK, "success", json.RawMessage(fileBytes)) +} diff --git a/rest/routes/semesters.go b/rest/routes/semesters.go new file mode 100644 index 00000000..4b5c44aa --- /dev/null +++ b/rest/routes/semesters.go @@ -0,0 +1,13 @@ +package routes + +import ( + "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/gin-gonic/gin" +) + +func SemestersRoute(router *gin.Engine) { + semestersGroup := router.Group("/semesters") + + semestersGroup.OPTIONS("", controllers.Preflight) + semestersGroup.GET("", controllers.Semesters) +} diff --git a/rest/server.go b/rest/server.go index 2cbf7ea6..439c7077 100644 --- a/rest/server.go +++ b/rest/server.go @@ -91,6 +91,7 @@ func main() { routes.ClubRoute(router) routes.DiscountRoutes(router) routes.BudgetRoute(router) + routes.SemestersRoute(router) // Retrieve the port string to serve traffic on portString := configs.GetPortString() diff --git a/semesters-data.json b/semesters-data.json new file mode 100644 index 00000000..b4282a81 --- /dev/null +++ b/semesters-data.json @@ -0,0 +1 @@ +["26u","26s","26f","25u","25s","25f","24u","24s","24f","23u","23s","23f","22u","22s","22f","21u","21s","21f","20u","20s","20f","19u","19s","19f","18u","18s"] \ No newline at end of file From b2f65ee45fc49d5df79f893b3eff7c8b92a1ac9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:43:03 +0000 Subject: [PATCH 47/73] Bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6 Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.1.4 to 4.1.6. - [Release notes](https://github.com/go-jose/go-jose/releases) - [Commits](https://github.com/go-jose/go-jose/compare/v4.1.4...v4.1.6) --- updated-dependencies: - dependency-name: github.com/go-jose/go-jose/v4 dependency-version: 4.1.6 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 8e12b373..3c190f5b 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 - github.com/wneessen/go-mail v0.8.1 go.mongodb.org/mongo-driver/v2 v2.9.1 google.golang.org/api v0.293.0 ) @@ -36,7 +35,7 @@ require ( github.com/envoyproxy/go-control-plane/envoy v1.39.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.3.3 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect - github.com/go-jose/go-jose/v4 v4.1.4 // indirect + github.com/go-jose/go-jose/v4 v4.1.6 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v1.0.0 // indirect diff --git a/go.sum b/go.sum index 82a0938c..8115b5eb 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8= github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA= -github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= +github.com/go-jose/go-jose/v4 v4.1.6 h1:sNRkftxFJxwsILiQukqp5z83QBSmntVwmgRY7AqBDO4= +github.com/go-jose/go-jose/v4 v4.1.6/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= From 0b264d37d9ae0e6a92d64c178b376087e4e2a817 Mon Sep 17 00:00:00 2001 From: Aydan Husby Date: Thu, 29 Oct 2026 16:11:43 -0500 Subject: [PATCH 48/73] Update env_test.go --- rest/configs/env_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index c83eb3da..7ee2f439 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -133,7 +133,7 @@ func TestGetClubsDBUri(t *testing.T) { } }) - t.Run("Unset panics", func(t *testing.T) { + /*t.Run("Unset panics", func(t *testing.T) { unsetEnv(t, "CLUBS_DB_URI") @@ -144,7 +144,7 @@ func TestGetClubsDBUri(t *testing.T) { }() GetClubsDBUri() - }) + })*/ } func TestGetEnvLogin(t *testing.T) { From 23a1b00c119dd46a1e42238574ce3b50683477f3 Mon Sep 17 00:00:00 2001 From: Ashwin Avadhanula Date: Mon, 2 Nov 2026 14:56:20 -0600 Subject: [PATCH 49/73] updated storage_test to run with fakestorage client --- go.mod | 7 +++ go.sum | 89 ++++++++++++++++++++++++++++++++ rest/controllers/storage_test.go | 10 ++-- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3c190f5b..f4444ee5 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( cloud.google.com/go/compute/metadata v0.9.0 // indirect cloud.google.com/go/iam v1.13.0 // indirect cloud.google.com/go/monitoring v1.30.0 // indirect + cloud.google.com/go/pubsub/v2 v2.6.2 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.60.0 // indirect @@ -35,6 +36,7 @@ require ( github.com/envoyproxy/go-control-plane/envoy v1.39.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.3.3 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect + github.com/fsouza/fake-gcs-server v1.56.1 // indirect github.com/go-jose/go-jose/v4 v4.1.6 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -43,17 +45,22 @@ require ( github.com/go-openapi/spec v0.22.9 // indirect github.com/go-openapi/swag/pools v0.29.1 // indirect github.com/goccy/go-yaml v1.19.2 // indirect + github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.21 // indirect github.com/googleapis/gax-go/v2 v2.24.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/pkg/xattr v0.4.12 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.61.0 // indirect github.com/spiffe/go-spiffe/v2 v2.8.1 // indirect + go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect diff --git a/go.sum b/go.sum index 8115b5eb..7a235712 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0= cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.123.0 h1:2NAUJwPR47q+E35uaJeYoNhuNEM9kM8SjgRgdeOJUSE= cloud.google.com/go v0.123.0/go.mod h1:xBoMV08QcqUGuPW65Qfm1o9Y4zKZBpGS+7bImXLTAZU= cloud.google.com/go/auth v0.23.2 h1:pxSCpfiji41hpzpPdMCftEUCezpgpqmmDdYiAjCKXxo= @@ -16,10 +17,13 @@ cloud.google.com/go/longrunning v1.2.0 h1:WjYH3YHBGCxGJP9M4dWGHBfXr/cFIjMkNgWcJj cloud.google.com/go/longrunning v1.2.0/go.mod h1:5KMQALFGOCtFoi2xSOA1u3H7WKlhmckgiyFw7+LGQp0= cloud.google.com/go/monitoring v1.30.0 h1:r/d+JUbyKmJ8b07iznuKfzVzrIXTWxHQ3lBRm3x2LlY= cloud.google.com/go/monitoring v1.30.0/go.mod h1:htlUR0QWVMrjFzZmN4LGnMAve9xB/eduwjmINxVZ8RM= +cloud.google.com/go/pubsub/v2 v2.6.2 h1:YPeEXnf4LZz9eVdpbXqBMRlxdwk4breCUsoIp7uDet4= +cloud.google.com/go/pubsub/v2 v2.6.2/go.mod h1:JaFvWNVRk3Knoil/4M1ECeLOaI9D8drbmJWypQlK5aM= cloud.google.com/go/storage v1.65.0 h1:McbFt5j+hTNx+dkFuzq7teakIKcpqGp/cJZRxMyfvAc= cloud.google.com/go/storage v1.65.0/go.mod h1:UsS9OgFg/XHOSYakQ8ZtLWWeyGkk1WnmD/GsGfN0BHM= cloud.google.com/go/trace v1.16.0 h1:GmQovzFc5F0CNfl0VLgL64aoTtu7xsM0YajW2GlG9+E= cloud.google.com/go/trace v1.16.0/go.mod h1:r+bdAn16dKLSV1G2D5v3e58IlQlizfxWrUfjx7kM7X0= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0 h1:3SdxXLkgAfiHRWcGTq6fneq9jgoJzneiY0yPQnjoT2E= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0/go.mod h1:1iIdl0k+ppn9wT0wzR9H7HkSvIui/4qgtnKW10cQtds= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 h1:HldzheTs05E3ybqSitI/wHaof6+XERRudgZLjYbs3eE= @@ -36,26 +40,35 @@ github.com/bytedance/sonic v1.15.2 h1:90H+rcF/FwLXwfB1cudOLq/je83n683Utf4Cbp0xHC github.com/bytedance/sonic v1.15.2/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA= github.com/bytedance/sonic/loader v0.5.2 h1:0QtP1gevc1OZ6/H8Lb9BRZiCXd1Ftjd3OKuj1T1lBIo= github.com/bytedance/sonic/loader v0.5.2/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI= github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2 h1:aBangftG7EVZoUb69Os8IaYg++6uMOdKK83QtkkvJik= github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2/go.mod h1:qwXFYgsP6T7XnJtbKlf1HP8AjxZZyzxMmc+Lq5GjlU4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA= github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU= github.com/envoyproxy/go-control-plane/envoy v1.39.0 h1:1uwRDYPYG8BIBU9Mj1sUAebNmlM6beu/ZKKweSLDxk8= github.com/envoyproxy/go-control-plane/envoy v1.39.0/go.mod h1:5e4ylfTZO723MEEFsCpSW4ZEBWR8mwkEyXfwJBTCZ9c= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.3.3 h1:MVQghNeW+LZcmXe7SY1V36Z+WFMDjpqGAGacLe2T0ds= github.com/envoyproxy/protoc-gen-validate v1.3.3/go.mod h1:TsndJ/ngyIdQRhMcVVGDDHINPLWB7C82oDArY51KfB0= github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= +github.com/fsouza/fake-gcs-server v1.56.1 h1:K03sAvbLvDz4hAynpCCUqnNRp+ik9JFSvHbkD/wTPOU= +github.com/fsouza/fake-gcs-server v1.56.1/go.mod h1:rzibfBNKouMLeVYDkIDqUiCEcfgDyJWe+4PhG7uesmU= github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI= github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ= github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY= @@ -116,21 +129,46 @@ github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU= github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= +github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= +github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.21 h1:OFdQ3tnCX/zaQ0Cedur3D3z7kI6HiLX9g3TiAN4/DFU= github.com/googleapis/enterprise-certificate-proxy v0.3.21/go.mod h1:L3D/IQExI6LqEjBdXcZQ1WluSgigQmSwBboFstVPM4w= github.com/googleapis/gax-go/v2 v2.24.0 h1:myMaPYyF9MecEmvQqMqomIwn9t/4KCZN9qnwsS76wlg= github.com/googleapis/gax-go/v2 v2.24.0/go.mod h1:IaTHBDd7NHxSCiu0vEs8pQZu4dGZrWwuSoxCnk16OFM= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= @@ -162,11 +200,14 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/xattr v0.4.12 h1:rRTkSyFNTRElv6pkA3zpjHpQ90p/OdHQC1GmGh1aTjM= +github.com/pkg/xattr v0.4.12/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6ktU= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0= github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk= github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= @@ -183,10 +224,12 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY= @@ -208,6 +251,8 @@ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfS github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mongodb.org/mongo-driver/v2 v2.9.1 h1:jewiFs2m1/VOQp8qhFshX6hWZ+EAXDhZHXExAUMcOgQ= go.mongodb.org/mongo-driver/v2 v2.9.1/go.mod h1:SHKN0IWkKmEVGHLjXnni6s4wPKX4v86FTgOeJJFuXcA= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/detectors/gcp v1.45.0 h1:9jR0ZPRok9ryaOQ2Wx8rg5F7Aon59mxrqbVI60/vlBk= @@ -239,27 +284,45 @@ go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/arch v0.30.0 h1:sB9h+1gRGa2+LauFSV0tm8bK1J2yo1bx6/Uyi/P6DTU= golang.org/x/arch v0.30.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -278,26 +341,52 @@ golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/api v0.293.0 h1:p9XIWOf63U4OgYx120ZwVU8+vl4XTPmWfgVPnmOAS9w= google.golang.org/api v0.293.0/go.mod h1:6n5tjEB1gzwniZTepZ0g5u+wM7Bof5GeULCx/zh8ZE0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688 h1:2ficYAs+4TBEqohUu9hr7J2YeNTie+3BVyqERjs5Hm0= google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688/go.mod h1:icDJeJwWhZtQDn/1WGql+0n01hbizh4G7/T75RoxcHs= google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI= google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4= google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/rest/controllers/storage_test.go b/rest/controllers/storage_test.go index b87a44bb..29707994 100644 --- a/rest/controllers/storage_test.go +++ b/rest/controllers/storage_test.go @@ -9,12 +9,13 @@ import ( "strings" "testing" - "cloud.google.com/go/storage" + "github.com/fsouza/fake-gcs-server/fakestorage" "github.com/gin-gonic/gin" ) func TestMaxUploadSize(t *testing.T) { // Set the environment variable for max upload size (e.g., 100 bytes) + if err := os.Setenv("MAX_UPLOAD_SIZE", "100"); err != nil { t.Fatalf("Error setting 'MAX_UPLOAD_SIZE'") } @@ -25,13 +26,16 @@ func TestMaxUploadSize(t *testing.T) { } }() + server := fakestorage.NewServer(nil) + defer server.Stop() + client := server.Client() + // Setup Gin gin.SetMode(gin.TestMode) router := gin.New() router.POST("/storage/:bucket/:objectID", func(c *gin.Context) { - - c.Set("gcsClient", &storage.Client{}) + c.Set("gcsClient", client) PostObject(c) }) From df65c02abc9b9dd3524665a343389ac0b307391b Mon Sep 17 00:00:00 2001 From: ThatRell Date: Sat, 7 Nov 2026 01:53:52 -0600 Subject: [PATCH 50/73] dynamic json file creation --- rest/controllers/semesters.go | 200 +++++++++++++++++++++++++++------- rest/docs/docs.go | 43 ++++++++ rest/docs/swagger.yaml | 29 +++++ rest/routes/semesters.go | 1 + semesters-data.json | 1 - 5 files changed, 233 insertions(+), 41 deletions(-) delete mode 100644 semesters-data.json diff --git a/rest/controllers/semesters.go b/rest/controllers/semesters.go index f25c308e..aeb0d790 100644 --- a/rest/controllers/semesters.go +++ b/rest/controllers/semesters.go @@ -1,62 +1,182 @@ package controllers import ( + "context" "encoding/json" "net/http" "os" + "sort" + "strconv" + "strings" + "sync" + "time" + _ "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson" ) -const testfilename = "semesters-data.json" +type cacheFile struct { + LastUpdated time.Time `json:"lastUpdated"` + Terms []string `json:"terms"` +} + +const ( + filename = "semesters.json" + fileTTL = 30 * 24 * time.Hour // 30 days +) + +var ( + semesters []string + lastUpdated time.Time + isLoaded bool + mutex sync.RWMutex +) +// @Id semesters +// @Router /semesters [get] +// @Tags Other +// @Description "Returns a list of all available terms in CourseBook, sorted by recency" +// @Produce json +// @Success 200 {object} schema.APIResponse[[]string] "A string list of all available terms, lowercased" +// @Failure 500 {object} schema.APIResponse[string] "A string describing the error" func Semesters(c *gin.Context) { - terms := []string{ - "26u", - "26s", - "26f", - "25u", - "25s", - "25f", - "24u", - "24s", - "24f", - "23u", - "23s", - "23f", - "22u", - "22s", - "22f", - "21u", - "21s", - "21f", - "20u", - "20s", - "20f", - "19u", - "19s", - "19f", - "18u", - "18s", - } - - jsonData, err := json.Marshal(terms) + ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) + defer cancel() + + mutex.RLock() + needsRefresh := !isLoaded || cacheExpired(lastUpdated) + mutex.RUnlock() + + if needsRefresh { + err := loadOrRefresh(ctx) + if err != nil { + respondWithInternalError(c, err) + return + } + } + + mutex.RLock() + data := semesters + mutex.RUnlock() + + respond(c, http.StatusOK, "success", data) +} + +func loadOrRefresh(ctx context.Context) error { + // Prevent other calls from r/w json file + mutex.Lock() + defer mutex.Unlock() + + if isLoaded && !cacheExpired(lastUpdated) { + return nil + } + + if !isLoaded { + // Check if json file exists + fileBytes, err := os.ReadFile(filename) + if err == nil { + var fileData cacheFile + if err := json.Unmarshal(fileBytes, &fileData); err == nil { + // Check if file data is outdated, load and return if not + if time.Since(fileData.LastUpdated) <= fileTTL { + semesters = fileData.Terms + lastUpdated = fileData.LastUpdated + isLoaded = true + return nil + } + } + } + } + + sortedTerms, err := getSortedTerms(ctx) + if err != nil { + return err + } + currTime := time.Now() + + newData := cacheFile{ + LastUpdated: currTime, + Terms: sortedTerms, + } + + fileBytes, err := json.Marshal(newData) if err != nil { - respondWithInternalError(c, err) - return + return err } - err = os.WriteFile(testfilename, jsonData, 0644) + // Create new json file with updated data + err = os.WriteFile(filename, fileBytes, 0644) if err != nil { - respondWithInternalError(c, err) - return + return err + } + + // Update global variables + semesters = sortedTerms + lastUpdated = currTime + isLoaded = true + + return nil +} + +func getSortedTerms(ctx context.Context) ([]string, error) { + + type term struct { + name string + year int + season string } - fileBytes, err := os.ReadFile(testfilename) + terms, err := sectionCollection.Distinct(ctx, "academic_session.name", bson.D{}) if err != nil { - respondWithInternalError(c, err) - return + return nil, err + } + + var parsedTerms []term + seen := make(map[string]struct{}) + + for _, t := range terms { + str, ok := t.(string) + if !ok || len(str) < 3 { + continue + } + + str = strings.ToLower(strings.TrimSpace(str)) + + // Solution to possible duplicate value case (if database query returns '24F' and '24f') + if _, exists := seen[str]; exists { + continue + } + + year, err := strconv.Atoi(str[:2]) + if err != nil { + continue + } + parsedTerms = append(parsedTerms, term{ + name: str, + year: year, + season: str[2:], + }) + } + + // Sort terms by recency + sort.Slice(parsedTerms, func(i, j int) bool { + if parsedTerms[i].year != parsedTerms[j].year { + return parsedTerms[i].year > parsedTerms[j].year + } + + // Sort by season (comparing ascii values) + return parsedTerms[i].season > parsedTerms[j].season + }) + + sortedTerms := make([]string, len(parsedTerms)) + for i, t := range parsedTerms { + sortedTerms[i] = t.name } - respond(c, http.StatusOK, "success", json.RawMessage(fileBytes)) + return sortedTerms, nil +} + +func cacheExpired(updatedAt time.Time) bool { + return updatedAt.IsZero() || time.Since(updatedAt) > fileTTL } diff --git a/rest/docs/docs.go b/rest/docs/docs.go index dd1079f7..4a71e4c0 100644 --- a/rest/docs/docs.go +++ b/rest/docs/docs.go @@ -3142,6 +3142,32 @@ const docTemplate = `{ } } }, + "/semesters": { + "get": { + "description": "\"Returns a list of all available terms in CourseBook, sorted by recency\"", + "produces": [ + "application/json" + ], + "tags": [ + "Other" + ], + "operationId": "semesters", + "responses": { + "200": { + "description": "A string list of all available terms, lowercased", + "schema": { + "$ref": "#/definitions/schema.APIResponse-array_string" + } + }, + "500": { + "description": "A string describing the error", + "schema": { + "$ref": "#/definitions/schema.APIResponse-string" + } + } + } + } + }, "/storage/{bucket}": { "get": { "description": "\"Get info on a bucket. This route is restricted to only Nebula Labs internal Projects.\"", @@ -3615,6 +3641,23 @@ const docTemplate = `{ } } }, + "schema.APIResponse-array_string": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "string" + } + }, + "message": { + "type": "string" + }, + "status": { + "type": "integer" + } + } + }, "schema.APIResponse-int": { "type": "object", "properties": { diff --git a/rest/docs/swagger.yaml b/rest/docs/swagger.yaml index 592ee3b9..95fb93fe 100644 --- a/rest/docs/swagger.yaml +++ b/rest/docs/swagger.yaml @@ -109,6 +109,17 @@ definitions: status: type: integer type: object + schema.APIResponse-array_string: + properties: + data: + items: + type: string + type: array + message: + type: string + status: + type: integer + type: object schema.APIResponse-int: properties: data: @@ -3332,6 +3343,24 @@ paths: $ref: '#/definitions/schema.APIResponse-string' tags: - Sections + /semesters: + get: + description: '"Returns a list of all available terms in CourseBook, sorted by + recency"' + operationId: semesters + produces: + - application/json + responses: + "200": + description: A string list of all available terms, lowercased + schema: + $ref: '#/definitions/schema.APIResponse-array_string' + "500": + description: A string describing the error + schema: + $ref: '#/definitions/schema.APIResponse-string' + tags: + - Other /storage/{bucket}: delete: description: '"Delete a bucket. This route is restricted to only Nebula Labs diff --git a/rest/routes/semesters.go b/rest/routes/semesters.go index 4b5c44aa..91998a2f 100644 --- a/rest/routes/semesters.go +++ b/rest/routes/semesters.go @@ -6,6 +6,7 @@ import ( ) func SemestersRoute(router *gin.Engine) { + // All routes related to semesters come here semestersGroup := router.Group("/semesters") semestersGroup.OPTIONS("", controllers.Preflight) diff --git a/semesters-data.json b/semesters-data.json deleted file mode 100644 index b4282a81..00000000 --- a/semesters-data.json +++ /dev/null @@ -1 +0,0 @@ -["26u","26s","26f","25u","25s","25f","24u","24s","24f","23u","23s","23f","22u","22s","22f","21u","21s","21f","20u","20s","20f","19u","19s","19f","18u","18s"] \ No newline at end of file From 34809f2f03d7333d846ccaee8416693fce921830 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 08:56:27 -0600 Subject: [PATCH 51/73] Switch to directive for forcing resolvers --- go.mod | 20 +- go.sum | 40 +- graphql/gqlgen.yml | 26 +- graphql/graph/generated.go | 1641 ++++++++++------------------- graphql/graph/schema.graphqls | 14 +- graphql/graph/schema.resolvers.go | 30 +- 6 files changed, 626 insertions(+), 1145 deletions(-) diff --git a/go.mod b/go.mod index f2410dd7..275ffdea 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.26.0 require ( cloud.google.com/go/storage v1.65.0 - github.com/99designs/gqlgen v0.17.95 + github.com/99designs/gqlgen v0.17.98 github.com/getsentry/sentry-go v0.48.0 github.com/getsentry/sentry-go/gin v0.48.0 github.com/gin-gonic/gin v1.12.0 @@ -13,7 +13,7 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 - github.com/vektah/gqlparser/v2 v2.5.37 + github.com/vektah/gqlparser/v2 v2.5.64 github.com/vikstrous/dataloadgen v0.0.10 github.com/wneessen/go-mail v0.8.1 go.mongodb.org/mongo-driver/v2 v2.9.1 @@ -32,7 +32,7 @@ require ( github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.60.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/agnivade/levenshtein v1.2.1 // indirect + github.com/agnivade/levenshtein v1.2.2 // indirect github.com/bytedance/sonic/loader v0.5.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.7 // indirect @@ -75,7 +75,7 @@ require ( go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/oauth2 v0.36.0 // indirect golang.org/x/time v0.15.0 // indirect - golang.org/x/tools v0.49.0 // indirect + golang.org/x/tools v0.52.0 // indirect google.golang.org/genproto v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect @@ -114,11 +114,11 @@ require ( github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect golang.org/x/arch v0.30.0 // indirect - golang.org/x/crypto v0.55.0 // indirect - golang.org/x/mod v0.40.0 // indirect - golang.org/x/net v0.58.0 // indirect - golang.org/x/sync v0.22.0 // indirect - golang.org/x/sys v0.47.0 // indirect - golang.org/x/text v0.41.0 // indirect + golang.org/x/crypto v0.58.0 // indirect + golang.org/x/mod v0.42.0 // indirect + golang.org/x/net v0.61.0 // indirect + golang.org/x/sync v0.24.0 // indirect + golang.org/x/sys v0.49.0 // indirect + golang.org/x/text v0.43.0 // indirect google.golang.org/protobuf v1.36.12 // indirect ) diff --git a/go.sum b/go.sum index 2813c28b..3bc6e68a 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ cloud.google.com/go/storage v1.65.0 h1:McbFt5j+hTNx+dkFuzq7teakIKcpqGp/cJZRxMyfv cloud.google.com/go/storage v1.65.0/go.mod h1:UsS9OgFg/XHOSYakQ8ZtLWWeyGkk1WnmD/GsGfN0BHM= cloud.google.com/go/trace v1.16.0 h1:GmQovzFc5F0CNfl0VLgL64aoTtu7xsM0YajW2GlG9+E= cloud.google.com/go/trace v1.16.0/go.mod h1:r+bdAn16dKLSV1G2D5v3e58IlQlizfxWrUfjx7kM7X0= -github.com/99designs/gqlgen v0.17.95 h1:882h7F5iJImgtyUVttc4MOK2NbzbMYc2oyNeHqkjpP4= -github.com/99designs/gqlgen v0.17.95/go.mod h1:kHYPrpwOXDU1OQyxIg3Z7nVXSnlUoHVWBY7CMJCAM4M= +github.com/99designs/gqlgen v0.17.98 h1:t7UTlygkXMx1tJmKyR0LxttcufXnJ7fF6fAaeHSofAc= +github.com/99designs/gqlgen v0.17.98/go.mod h1:tIoiUl+cgIT7nayvObZkKDgplxd1pHcUAmEXAyv+8f4= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0 h1:3SdxXLkgAfiHRWcGTq6fneq9jgoJzneiY0yPQnjoT2E= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.36.0/go.mod h1:1iIdl0k+ppn9wT0wzR9H7HkSvIui/4qgtnKW10cQtds= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.60.0 h1:HldzheTs05E3ybqSitI/wHaof6+XERRudgZLjYbs3eE= @@ -34,8 +34,8 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.60.0/go.mod h1:SRAbhyZ4R4FagHMM9VtRgSY/lheRoht2fKelZXQUenk= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM= -github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= +github.com/agnivade/levenshtein v1.2.2 h1:fI8RgiztYX1Nn5pBHHqQ9EMCCklhrmXqPRIedFmx5M4= +github.com/agnivade/levenshtein v1.2.2/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM= @@ -213,8 +213,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= -github.com/vektah/gqlparser/v2 v2.5.37 h1:jbb1Ilv+xBklV6653tKb4oVUupPNTLb5LmrnBKVI12Y= -github.com/vektah/gqlparser/v2 v2.5.37/go.mod h1:9O4Ox6Ngd3Y12bMD3w6i3CRQXh8W1oC1q0m6olCymDM= +github.com/vektah/gqlparser/v2 v2.5.64 h1:N32yM6hQ6Kd5RdjCCEJsUrbCebVoA9yLLMOIa88Mkk0= +github.com/vektah/gqlparser/v2 v2.5.64/go.mod h1:nILRSUbsWDTuf8hSmAgFxuYh0SaMZdkvl6JSEbkJX8g= github.com/vikstrous/dataloadgen v0.0.10 h1:x07XAeEjIWXohvcjRvE72KY8pV5A3sTbKEFmxcj9RNM= github.com/vikstrous/dataloadgen v0.0.10/go.mod h1:8vuQVpBH0ODbMKAPUdCAPcOGezoTIhgAjgex51t4vbg= github.com/wneessen/go-mail v0.8.1 h1:tVcncj02/QySVFw3zr/kXOzZcuFQqBNT6K+Rbgm/pcM= @@ -262,31 +262,31 @@ golang.org/x/arch v0.30.0 h1:sB9h+1gRGa2+LauFSV0tm8bK1J2yo1bx6/Uyi/P6DTU= golang.org/x/arch v0.30.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= -golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= +golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= -golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= +golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg= +golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= -golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= +golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw= +golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= -golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= +golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= -golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= +golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -295,15 +295,15 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= -golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= -golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= +golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= +golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml index 05ee6fdc..2e521ce5 100644 --- a/graphql/gqlgen.yml +++ b/graphql/gqlgen.yml @@ -161,26 +161,6 @@ models: Any: model: - github.com/99designs/gqlgen/graphql.Any - - # Forcing field resolvers - Course: - fields: - sections: - resolver: true - - Section: - fields: - course_reference: - resolver: true - professors: - resolver: true - - Professor: - fields: - sections: - resolver: true - - SectionWithTime: - fields: - section: - resolver: true \ No newline at end of file + ObjectID: + model: + - github.com/UTDNebula/nebula-api/graphql/graph/model.ObjectID \ No newline at end of file diff --git a/graphql/graph/generated.go b/graphql/graph/generated.go index 981090b6..a8adc1eb 100644 --- a/graphql/graph/generated.go +++ b/graphql/graph/generated.go @@ -1330,15 +1330,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputCometCalendarBuildingInput, - ec.unmarshalInputCometCalendarFilter, - ec.unmarshalInputCometCalendarRoomInput, - ec.unmarshalInputCourseFilter, - ec.unmarshalInputEventInput, - ec.unmarshalInputProfessorFilter, - ec.unmarshalInputSectionFilter, - ) + inputUnmarshalers := func() *graphql.InputUnmarshalerIndex { + return graphql.NewInputUnmarshalerIndex( + graphql.NewInputUnmarshaler("CometCalendarBuildingInput", ec.unmarshalInputCometCalendarBuildingInput), + graphql.NewInputUnmarshaler("CometCalendarFilter", ec.unmarshalInputCometCalendarFilter), + graphql.NewInputUnmarshaler("CometCalendarRoomInput", ec.unmarshalInputCometCalendarRoomInput), + graphql.NewInputUnmarshaler("CourseFilter", ec.unmarshalInputCourseFilter), + graphql.NewInputUnmarshaler("EventInput", ec.unmarshalInputEventInput), + graphql.NewInputUnmarshaler("ProfessorFilter", ec.unmarshalInputProfessorFilter), + graphql.NewInputUnmarshaler("SectionFilter", ec.unmarshalInputSectionFilter), + ) + } first := true switch opCtx.Operation.Operation { @@ -1348,7 +1350,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { var data graphql.Marshaler if first { first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + ctx = graphql.WithLazyInputUnmarshalerIndex(ctx, inputUnmarshalers) data = ec._Query(ctx, opCtx.Operation.SelectionSet) } else { if atomic.LoadInt32(&ec.PendingDeferred) > 0 { @@ -2229,8 +2231,8 @@ func (ec *executionContext) field___Directive_args_args(ctx context.Context, raw var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", - func(ctx context.Context, v any) (*bool, error) { - return ec.unmarshalOBoolean2ᚖbool(ctx, v) + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) }) if err != nil { return nil, err @@ -2243,8 +2245,8 @@ func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", - func(ctx context.Context, v any) (*bool, error) { - return ec.unmarshalOBoolean2ᚖbool(ctx, v) + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) }) if err != nil { return nil, err @@ -2281,6 +2283,20 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field___Type_inputFields_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", + func(ctx context.Context, v any) (bool, error) { + return ec.unmarshalOBoolean2bool(ctx, v) + }) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + // endregion ***************************** args.gotpl ***************************** // region **************************** field.gotpl ***************************** @@ -2305,7 +2321,7 @@ func (ec *executionContext) _AcademicSession_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_AcademicSession_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "String") } func (ec *executionContext) _AcademicSession_start_date(ctx context.Context, field graphql.CollectedField, obj *model.AcademicSession) (ret graphql.Marshaler) { @@ -2328,7 +2344,7 @@ func (ec *executionContext) _AcademicSession_start_date(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_AcademicSession_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "DateTime") } func (ec *executionContext) _AcademicSession_end_date(ctx context.Context, field graphql.CollectedField, obj *model.AcademicSession) (ret graphql.Marshaler) { @@ -2351,7 +2367,7 @@ func (ec *executionContext) _AcademicSession_end_date(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AcademicSession_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AcademicSession", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("AcademicSession", field, false, false, "DateTime") } func (ec *executionContext) _Assistant_first_name(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2374,7 +2390,7 @@ func (ec *executionContext) _Assistant_first_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Assistant_first_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_last_name(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2397,7 +2413,7 @@ func (ec *executionContext) _Assistant_last_name(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Assistant_last_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_role(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2420,7 +2436,7 @@ func (ec *executionContext) _Assistant_role(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Assistant_role(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _Assistant_email(ctx context.Context, field graphql.CollectedField, obj *model.Assistant) (ret graphql.Marshaler) { @@ -2443,7 +2459,7 @@ func (ec *executionContext) _Assistant_email(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_Assistant_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Assistant", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Assistant", field, false, false, "String") } func (ec *executionContext) _AstraBuilding_building(ctx context.Context, field graphql.CollectedField, obj *model.AstraBuilding) (ret graphql.Marshaler) { @@ -2466,7 +2482,7 @@ func (ec *executionContext) _AstraBuilding_building(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_AstraBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraBuilding", field, false, false, "String") } func (ec *executionContext) _AstraBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.AstraBuilding) (ret graphql.Marshaler) { @@ -2521,7 +2537,7 @@ func (ec *executionContext) _AstraDayEvents_date(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraDayEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraDayEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraDayEvents", field, false, false, "String") } func (ec *executionContext) _AstraDayEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.AstraDayEvents) (ret graphql.Marshaler) { @@ -2576,7 +2592,7 @@ func (ec *executionContext) _AstraEvent_activity_name(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_activity_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_meeting_type(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2599,7 +2615,7 @@ func (ec *executionContext) _AstraEvent_meeting_type(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_meeting_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_start_date(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2622,7 +2638,7 @@ func (ec *executionContext) _AstraEvent_start_date(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_AstraEvent_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_end_date(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2645,7 +2661,7 @@ func (ec *executionContext) _AstraEvent_end_date(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraEvent_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_current_state(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2668,7 +2684,7 @@ func (ec *executionContext) _AstraEvent_current_state(ctx context.Context, field ) } func (ec *executionContext) fieldContext_AstraEvent_current_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_not_allowed_usage_mask(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2691,7 +2707,7 @@ func (ec *executionContext) _AstraEvent_not_allowed_usage_mask(ctx context.Conte ) } func (ec *executionContext) fieldContext_AstraEvent_not_allowed_usage_mask(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "Float64") } func (ec *executionContext) _AstraEvent_usage_color(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2714,7 +2730,7 @@ func (ec *executionContext) _AstraEvent_usage_color(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_AstraEvent_usage_color(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "String") } func (ec *executionContext) _AstraEvent_capacity(ctx context.Context, field graphql.CollectedField, obj *model.AstraEvent) (ret graphql.Marshaler) { @@ -2737,7 +2753,7 @@ func (ec *executionContext) _AstraEvent_capacity(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_AstraEvent_capacity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("AstraEvent", field, false, false, "Float64") } func (ec *executionContext) _AstraRoom_room(ctx context.Context, field graphql.CollectedField, obj *model.AstraRoom) (ret graphql.Marshaler) { @@ -2760,7 +2776,7 @@ func (ec *executionContext) _AstraRoom_room(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_AstraRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("AstraRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("AstraRoom", field, false, false, "String") } func (ec *executionContext) _AstraRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.AstraRoom) (ret graphql.Marshaler) { @@ -2815,7 +2831,7 @@ func (ec *executionContext) _BuildingRooms_building(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_BuildingRooms_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "String") } func (ec *executionContext) _BuildingRooms_rooms(ctx context.Context, field graphql.CollectedField, obj *model.BuildingRooms) (ret graphql.Marshaler) { @@ -2870,7 +2886,7 @@ func (ec *executionContext) _BuildingRooms_lat(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_BuildingRooms_lat(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "Float64") } func (ec *executionContext) _BuildingRooms_lon(ctx context.Context, field graphql.CollectedField, obj *model.BuildingRooms) (ret graphql.Marshaler) { @@ -2893,7 +2909,7 @@ func (ec *executionContext) _BuildingRooms_lon(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_BuildingRooms_lon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("BuildingRooms", field, false, false, "Float64") } func (ec *executionContext) _CollectionRequirement_type(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2916,7 +2932,7 @@ func (ec *executionContext) _CollectionRequirement_type(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_CollectionRequirement_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "String") } func (ec *executionContext) _CollectionRequirement_name(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2939,7 +2955,7 @@ func (ec *executionContext) _CollectionRequirement_name(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_CollectionRequirement_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "String") } func (ec *executionContext) _CollectionRequirement_required(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2962,7 +2978,7 @@ func (ec *executionContext) _CollectionRequirement_required(ctx context.Context, ) } func (ec *executionContext) fieldContext_CollectionRequirement_required(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "Int") } func (ec *executionContext) _CollectionRequirement_options(ctx context.Context, field graphql.CollectedField, obj *model.CollectionRequirement) (ret graphql.Marshaler) { @@ -2985,7 +3001,7 @@ func (ec *executionContext) _CollectionRequirement_options(ctx context.Context, ) } func (ec *executionContext) fieldContext_CollectionRequirement_options(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("CollectionRequirement", field, false, false, "Any") } func (ec *executionContext) _CometCalendar__id(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3008,7 +3024,7 @@ func (ec *executionContext) _CometCalendar__id(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_CometCalendar__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendar", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "ID") } func (ec *executionContext) _CometCalendar_date(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3031,7 +3047,7 @@ func (ec *executionContext) _CometCalendar_date(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_CometCalendar_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendar", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "String") } func (ec *executionContext) _CometCalendar_buildings(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3086,7 +3102,7 @@ func (ec *executionContext) _CometCalendarBuilding_building(ctx context.Context, ) } func (ec *executionContext) fieldContext_CometCalendarBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendarBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendarBuilding", field, false, false, "String") } func (ec *executionContext) _CometCalendarBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendarBuilding) (ret graphql.Marshaler) { @@ -3141,7 +3157,7 @@ func (ec *executionContext) _CometCalendarRoom_room(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_CometCalendarRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendarRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("CometCalendarRoom", field, false, false, "String") } func (ec *executionContext) _CometCalendarRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendarRoom) (ret graphql.Marshaler) { @@ -3196,7 +3212,7 @@ func (ec *executionContext) _Course__id(ctx context.Context, field graphql.Colle ) } func (ec *executionContext) fieldContext_Course__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "ID") } func (ec *executionContext) _Course_subject_prefix(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3219,7 +3235,7 @@ func (ec *executionContext) _Course_subject_prefix(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Course_subject_prefix(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_course_number(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3242,7 +3258,7 @@ func (ec *executionContext) _Course_course_number(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Course_course_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_title(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3265,7 +3281,7 @@ func (ec *executionContext) _Course_title(ctx context.Context, field graphql.Col ) } func (ec *executionContext) fieldContext_Course_title(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_description(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3288,7 +3304,7 @@ func (ec *executionContext) _Course_description(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Course_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_enrollment_reqs(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3311,7 +3327,7 @@ func (ec *executionContext) _Course_enrollment_reqs(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Course_enrollment_reqs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_school(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3334,7 +3350,7 @@ func (ec *executionContext) _Course_school(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Course_school(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_credit_hours(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3357,7 +3373,7 @@ func (ec *executionContext) _Course_credit_hours(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Course_credit_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_class_level(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3380,7 +3396,7 @@ func (ec *executionContext) _Course_class_level(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Course_class_level(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_activity_type(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3403,7 +3419,7 @@ func (ec *executionContext) _Course_activity_type(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Course_activity_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_grading(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3426,7 +3442,7 @@ func (ec *executionContext) _Course_grading(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Course_grading(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_internal_course_number(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3449,7 +3465,7 @@ func (ec *executionContext) _Course_internal_course_number(ctx context.Context, ) } func (ec *executionContext) fieldContext_Course_internal_course_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_prerequisites(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3600,7 +3616,7 @@ func (ec *executionContext) _Course_lecture_contact_hours(ctx context.Context, f ) } func (ec *executionContext) fieldContext_Course_lecture_contact_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_laboratory_contact_hours(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3623,7 +3639,7 @@ func (ec *executionContext) _Course_laboratory_contact_hours(ctx context.Context ) } func (ec *executionContext) fieldContext_Course_laboratory_contact_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_offering_frequency(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3646,7 +3662,7 @@ func (ec *executionContext) _Course_offering_frequency(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_Course_offering_frequency(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_catalog_year(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3669,7 +3685,7 @@ func (ec *executionContext) _Course_catalog_year(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Course_catalog_year(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "String") } func (ec *executionContext) _Course_attributes(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3692,7 +3708,7 @@ func (ec *executionContext) _Course_attributes(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Course_attributes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Course", field, false, false, "Any") } func (ec *executionContext) _Event__id(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3715,7 +3731,7 @@ func (ec *executionContext) _Event__id(ctx context.Context, field graphql.Collec ) } func (ec *executionContext) fieldContext_Event__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "ID") } func (ec *executionContext) _Event_summary(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3738,7 +3754,7 @@ func (ec *executionContext) _Event_summary(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Event_summary(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_location(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3761,7 +3777,7 @@ func (ec *executionContext) _Event_location(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Event_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_start_time(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3784,7 +3800,7 @@ func (ec *executionContext) _Event_start_time(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "DateTime") } func (ec *executionContext) _Event_end_time(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3807,7 +3823,7 @@ func (ec *executionContext) _Event_end_time(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Event_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "DateTime") } func (ec *executionContext) _Event_description(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3830,7 +3846,7 @@ func (ec *executionContext) _Event_description(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Event_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_type(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3853,7 +3869,7 @@ func (ec *executionContext) _Event_event_type(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_event_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_target_audience(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3876,7 +3892,7 @@ func (ec *executionContext) _Event_target_audience(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Event_target_audience(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_topic(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3899,7 +3915,7 @@ func (ec *executionContext) _Event_topic(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext_Event_topic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_tags(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3922,7 +3938,7 @@ func (ec *executionContext) _Event_event_tags(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_event_tags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_event_website(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3945,7 +3961,7 @@ func (ec *executionContext) _Event_event_website(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Event_event_website(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_department(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3968,7 +3984,7 @@ func (ec *executionContext) _Event_department(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Event_department(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_name(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -3991,7 +4007,7 @@ func (ec *executionContext) _Event_contact_name(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Event_contact_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_email(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -4014,7 +4030,7 @@ func (ec *executionContext) _Event_contact_email(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Event_contact_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Event_contact_phone_number(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -4037,7 +4053,7 @@ func (ec *executionContext) _Event_contact_phone_number(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_Event_contact_phone_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Event", field, false, false, "String") } func (ec *executionContext) _Location_building(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4060,7 +4076,7 @@ func (ec *executionContext) _Location_building(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext_Location_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _Location_room(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4083,7 +4099,7 @@ func (ec *executionContext) _Location_room(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Location_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _Location_map_uri(ctx context.Context, field graphql.CollectedField, obj *model.Location) (ret graphql.Marshaler) { @@ -4106,7 +4122,7 @@ func (ec *executionContext) _Location_map_uri(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Location_map_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Location", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Location", field, false, false, "String") } func (ec *executionContext) _MazevoBuilding_building(ctx context.Context, field graphql.CollectedField, obj *model.MazevoBuilding) (ret graphql.Marshaler) { @@ -4129,7 +4145,7 @@ func (ec *executionContext) _MazevoBuilding_building(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoBuilding_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoBuilding", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoBuilding", field, false, false, "String") } func (ec *executionContext) _MazevoBuilding_rooms(ctx context.Context, field graphql.CollectedField, obj *model.MazevoBuilding) (ret graphql.Marshaler) { @@ -4184,7 +4200,7 @@ func (ec *executionContext) _MazevoDayEvents_date(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_MazevoDayEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoDayEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoDayEvents", field, false, false, "String") } func (ec *executionContext) _MazevoDayEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.MazevoDayEvents) (ret graphql.Marshaler) { @@ -4239,7 +4255,7 @@ func (ec *executionContext) _MazevoEvent_event_name(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_MazevoEvent_event_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_organization_name(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4262,7 +4278,7 @@ func (ec *executionContext) _MazevoEvent_organization_name(ctx context.Context, ) } func (ec *executionContext) fieldContext_MazevoEvent_organization_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_contact_name(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4285,7 +4301,7 @@ func (ec *executionContext) _MazevoEvent_contact_name(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoEvent_contact_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_setup_minutes(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4308,7 +4324,7 @@ func (ec *executionContext) _MazevoEvent_setup_minutes(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_MazevoEvent_setup_minutes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "Float64") } func (ec *executionContext) _MazevoEvent_date_time_start(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4331,7 +4347,7 @@ func (ec *executionContext) _MazevoEvent_date_time_start(ctx context.Context, fi ) } func (ec *executionContext) fieldContext_MazevoEvent_date_time_start(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_date_time_end(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4354,7 +4370,7 @@ func (ec *executionContext) _MazevoEvent_date_time_end(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext_MazevoEvent_date_time_end(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_teardown_minutes(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4377,7 +4393,7 @@ func (ec *executionContext) _MazevoEvent_teardown_minutes(ctx context.Context, f ) } func (ec *executionContext) fieldContext_MazevoEvent_teardown_minutes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type Float64 does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "Float64") } func (ec *executionContext) _MazevoEvent_status_description(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4400,7 +4416,7 @@ func (ec *executionContext) _MazevoEvent_status_description(ctx context.Context, ) } func (ec *executionContext) fieldContext_MazevoEvent_status_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoEvent_status_color(ctx context.Context, field graphql.CollectedField, obj *model.MazevoEvent) (ret graphql.Marshaler) { @@ -4423,7 +4439,7 @@ func (ec *executionContext) _MazevoEvent_status_color(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MazevoEvent_status_color(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoEvent", field, false, false, "String") } func (ec *executionContext) _MazevoRoom_room(ctx context.Context, field graphql.CollectedField, obj *model.MazevoRoom) (ret graphql.Marshaler) { @@ -4446,7 +4462,7 @@ func (ec *executionContext) _MazevoRoom_room(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_MazevoRoom_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MazevoRoom", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MazevoRoom", field, false, false, "String") } func (ec *executionContext) _MazevoRoom_events(ctx context.Context, field graphql.CollectedField, obj *model.MazevoRoom) (ret graphql.Marshaler) { @@ -4501,7 +4517,7 @@ func (ec *executionContext) _Meeting_start_date(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Meeting_start_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "DateTime") } func (ec *executionContext) _Meeting_end_date(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4524,7 +4540,7 @@ func (ec *executionContext) _Meeting_end_date(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_end_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type DateTime does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "DateTime") } func (ec *executionContext) _Meeting_meeting_days(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4547,7 +4563,7 @@ func (ec *executionContext) _Meeting_meeting_days(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Meeting_meeting_days(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_start_time(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4570,7 +4586,7 @@ func (ec *executionContext) _Meeting_start_time(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Meeting_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_end_time(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4593,7 +4609,7 @@ func (ec *executionContext) _Meeting_end_time(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_modality(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4616,7 +4632,7 @@ func (ec *executionContext) _Meeting_modality(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Meeting_modality(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Meeting", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Meeting", field, false, false, "String") } func (ec *executionContext) _Meeting_location(ctx context.Context, field graphql.CollectedField, obj *model.Meeting) (ret graphql.Marshaler) { @@ -4671,7 +4687,7 @@ func (ec *executionContext) _MultiBuildingEvents_date(ctx context.Context, field ) } func (ec *executionContext) fieldContext_MultiBuildingEvents_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("MultiBuildingEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("MultiBuildingEvents", field, false, false, "String") } func (ec *executionContext) _MultiBuildingEvents_buildings(ctx context.Context, field graphql.CollectedField, obj *model.MultiBuildingEvents) (ret graphql.Marshaler) { @@ -4726,7 +4742,7 @@ func (ec *executionContext) _Office_building(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_Office_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Office", field, false, false, "String") } func (ec *executionContext) _Office_map_uri(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { @@ -4749,7 +4765,7 @@ func (ec *executionContext) _Office_map_uri(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext_Office_map_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Office", field, false, false, "String") } func (ec *executionContext) _Office_room(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { @@ -4772,7 +4788,7 @@ func (ec *executionContext) _Office_room(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext_Office_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Office", field, false, false, "String") } func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4795,7 +4811,7 @@ func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Professor__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "ID") } func (ec *executionContext) _Professor_first_name(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4818,7 +4834,7 @@ func (ec *executionContext) _Professor_first_name(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Professor_first_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_last_name(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4841,7 +4857,7 @@ func (ec *executionContext) _Professor_last_name(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Professor_last_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_titles(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4864,7 +4880,7 @@ func (ec *executionContext) _Professor_titles(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext_Professor_titles(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_email(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4887,7 +4903,7 @@ func (ec *executionContext) _Professor_email(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_Professor_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_phone_number(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4910,7 +4926,7 @@ func (ec *executionContext) _Professor_phone_number(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Professor_phone_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_office(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4965,7 +4981,7 @@ func (ec *executionContext) _Professor_profile_uri(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext_Professor_profile_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_image_uri(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4988,7 +5004,7 @@ func (ec *executionContext) _Professor_image_uri(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext_Professor_image_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "String") } func (ec *executionContext) _Professor_office_hours(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -5011,7 +5027,7 @@ func (ec *executionContext) _Professor_office_hours(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Professor_office_hours(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Professor", field, false, false, "Any") } func (ec *executionContext) _Professor_sections(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -5707,10 +5723,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }, nil, func(ctx context.Context, selections ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, selections, v) + return ec.marshalN__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, selections, v) }, true, - false, + true, ) } func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5746,7 +5762,7 @@ func (ec *executionContext) _Room_room(ctx context.Context, field graphql.Collec ) } func (ec *executionContext) fieldContext_Room_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Room", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Room", field, false, false, "String") } func (ec *executionContext) _Room_capacity(ctx context.Context, field graphql.CollectedField, obj *model.Room) (ret graphql.Marshaler) { @@ -5769,7 +5785,7 @@ func (ec *executionContext) _Room_capacity(ctx context.Context, field graphql.Co ) } func (ec *executionContext) fieldContext_Room_capacity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Room", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("Room", field, false, false, "Int") } func (ec *executionContext) _RoomEvents_room(ctx context.Context, field graphql.CollectedField, obj *model.RoomEvents) (ret graphql.Marshaler) { @@ -5792,7 +5808,7 @@ func (ec *executionContext) _RoomEvents_room(ctx context.Context, field graphql. ) } func (ec *executionContext) fieldContext_RoomEvents_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("RoomEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("RoomEvents", field, false, false, "String") } func (ec *executionContext) _RoomEvents_section_events(ctx context.Context, field graphql.CollectedField, obj *model.RoomEvents) (ret graphql.Marshaler) { @@ -5847,7 +5863,7 @@ func (ec *executionContext) _Section__id(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext_Section__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type ID does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "ID") } func (ec *executionContext) _Section_section_number(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -5870,7 +5886,7 @@ func (ec *executionContext) _Section_section_number(ctx context.Context, field g ) } func (ec *executionContext) fieldContext_Section_section_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_course_reference(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6053,7 +6069,7 @@ func (ec *executionContext) _Section_internal_class_number(ctx context.Context, ) } func (ec *executionContext) fieldContext_Section_internal_class_number(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_instruction_mode(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6076,7 +6092,7 @@ func (ec *executionContext) _Section_instruction_mode(ctx context.Context, field ) } func (ec *executionContext) fieldContext_Section_instruction_mode(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_meetings(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6131,7 +6147,7 @@ func (ec *executionContext) _Section_core_flags(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Section_core_flags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_syllabus_uri(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6154,7 +6170,7 @@ func (ec *executionContext) _Section_syllabus_uri(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext_Section_syllabus_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "String") } func (ec *executionContext) _Section_grade_distribution(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6177,7 +6193,7 @@ func (ec *executionContext) _Section_grade_distribution(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_Section_grade_distribution(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type Int does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "Int") } func (ec *executionContext) _Section_attributes(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -6200,7 +6216,7 @@ func (ec *executionContext) _Section_attributes(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext_Section_attributes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, errors.New("field of type Any does not have child fields")) + return graphql.NewScalarFieldContext("Section", field, false, false, "Any") } func (ec *executionContext) _SectionWithTime_section(ctx context.Context, field graphql.CollectedField, obj *model.SectionWithTime) (ret graphql.Marshaler) { @@ -6255,7 +6271,7 @@ func (ec *executionContext) _SectionWithTime_start_time(ctx context.Context, fie ) } func (ec *executionContext) fieldContext_SectionWithTime_start_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, "String") } func (ec *executionContext) _SectionWithTime_end_time(ctx context.Context, field graphql.CollectedField, obj *model.SectionWithTime) (ret graphql.Marshaler) { @@ -6278,7 +6294,7 @@ func (ec *executionContext) _SectionWithTime_end_time(ctx context.Context, field ) } func (ec *executionContext) fieldContext_SectionWithTime_end_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SectionWithTime", field, false, false, "String") } func (ec *executionContext) _SingleBuildingEvents_building(ctx context.Context, field graphql.CollectedField, obj *model.SingleBuildingEvents) (ret graphql.Marshaler) { @@ -6301,7 +6317,7 @@ func (ec *executionContext) _SingleBuildingEvents_building(ctx context.Context, ) } func (ec *executionContext) fieldContext_SingleBuildingEvents_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("SingleBuildingEvents", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("SingleBuildingEvents", field, false, false, "String") } func (ec *executionContext) _SingleBuildingEvents_rooms(ctx context.Context, field graphql.CollectedField, obj *model.SingleBuildingEvents) (ret graphql.Marshaler) { @@ -6356,7 +6372,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "String") } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6379,7 +6395,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, true, false, "String") } func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6402,7 +6418,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field ) } func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "Boolean") } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6425,7 +6441,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Directive", field, false, false, errors.New("field of type __DirectiveLocation does not have child fields")) + return graphql.NewScalarFieldContext("__Directive", field, false, false, "__DirectiveLocation") } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { @@ -6437,7 +6453,8 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return ec.fieldContext___Directive_args(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.Args, nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleArgs(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -6451,7 +6468,7 @@ func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, f fc = &graphql.FieldContext{ Object: "__Directive", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return ec.childFields___InputValue(ctx, field) @@ -6491,7 +6508,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ) } func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, false, false, "String") } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6514,7 +6531,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "String") } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6537,7 +6554,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ) } func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "Boolean") } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { @@ -6560,7 +6577,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ) } func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__EnumValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__EnumValue", field, true, false, "String") } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6583,7 +6600,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ) } func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, false, false, "String") } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6606,7 +6623,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ) } func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "String") } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6618,7 +6635,8 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return ec.fieldContext___Field_args(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.Args, nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleArgs(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -6632,7 +6650,7 @@ func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field fc = &graphql.FieldContext{ Object: "__Field", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return ec.childFields___InputValue(ctx, field) @@ -6704,7 +6722,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "Boolean") } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { @@ -6727,7 +6745,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Field", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Field", field, true, false, "String") } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6750,7 +6768,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ) } func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, false, false, "String") } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6773,7 +6791,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ) } func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "String") } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6828,7 +6846,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, false, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, false, false, "String") } func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6851,7 +6869,7 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel ) } func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "Boolean") } func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { @@ -6874,7 +6892,7 @@ func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, ) } func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__InputValue", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__InputValue", field, true, false, "String") } func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { @@ -6897,7 +6915,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra ) } func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Schema", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Schema", field, true, false, "String") } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { @@ -7080,7 +7098,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type __TypeKind does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "__TypeKind") } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7103,7 +7121,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ) } func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7126,7 +7144,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ) } func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7149,7 +7167,7 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr ) } func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type String does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "String") } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { @@ -7313,7 +7331,8 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return ec.fieldContext___Type_inputFields(ctx, field) }, func(ctx context.Context) (any, error) { - return obj.InputFields(), nil + fc := graphql.GetFieldContext(ctx) + return obj.VisibleInputFields(fc.Args["includeDeprecated"].(bool)), nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { @@ -7323,7 +7342,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph false, ) } -func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -7333,6 +7352,17 @@ func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, f return ec.childFields___InputValue(ctx, field) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_inputFields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } @@ -7388,7 +7418,7 @@ func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.C ) } func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("__Type", field, true, false, errors.New("field of type Boolean does not have child fields")) + return graphql.NewScalarFieldContext("__Type", field, true, false, "Boolean") } // endregion **************************** field.gotpl ***************************** @@ -7432,6 +7462,18 @@ func (ec *executionContext) unmarshalInputCometCalendarBuildingInput(ctx context return it, nil } +// UnmarshalCometCalendarBuildingInput unmarshals raw into the CometCalendarBuildingInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarBuildingInput(ctx context.Context, raw any) (model.CometCalendarBuildingInput, error) { + var out model.CometCalendarBuildingInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarBuildingInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCometCalendarFilter(ctx context.Context, obj any) (model.CometCalendarFilter, error) { var it model.CometCalendarFilter if obj == nil { @@ -7469,6 +7511,18 @@ func (ec *executionContext) unmarshalInputCometCalendarFilter(ctx context.Contex return it, nil } +// UnmarshalCometCalendarFilter unmarshals raw into the CometCalendarFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarFilter(ctx context.Context, raw any) (model.CometCalendarFilter, error) { + var out model.CometCalendarFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCometCalendarRoomInput(ctx context.Context, obj any) (model.CometCalendarRoomInput, error) { var it model.CometCalendarRoomInput if obj == nil { @@ -7506,6 +7560,18 @@ func (ec *executionContext) unmarshalInputCometCalendarRoomInput(ctx context.Con return it, nil } +// UnmarshalCometCalendarRoomInput unmarshals raw into the CometCalendarRoomInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCometCalendarRoomInput(ctx context.Context, raw any) (model.CometCalendarRoomInput, error) { + var out model.CometCalendarRoomInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "CometCalendarRoomInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputCourseFilter(ctx context.Context, obj any) (model.CourseFilter, error) { var it model.CourseFilter if obj == nil { @@ -7613,6 +7679,18 @@ func (ec *executionContext) unmarshalInputCourseFilter(ctx context.Context, obj return it, nil } +// UnmarshalCourseFilter unmarshals raw into the CourseFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalCourseFilter(ctx context.Context, raw any) (model.CourseFilter, error) { + var out model.CourseFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "CourseFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputEventInput(ctx context.Context, obj any) (model.EventInput, error) { var it model.EventInput if obj == nil { @@ -7692,6 +7770,18 @@ func (ec *executionContext) unmarshalInputEventInput(ctx context.Context, obj an return it, nil } +// UnmarshalEventInput unmarshals raw into the EventInput input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalEventInput(ctx context.Context, raw any) (model.EventInput, error) { + var out model.EventInput + err := graphql.UnmarshalNamedInputFromContext(ctx, "EventInput", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputProfessorFilter(ctx context.Context, obj any) (model.ProfessorFilter, error) { var it model.ProfessorFilter if obj == nil { @@ -7750,6 +7840,18 @@ func (ec *executionContext) unmarshalInputProfessorFilter(ctx context.Context, o return it, nil } +// UnmarshalProfessorFilter unmarshals raw into the ProfessorFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalProfessorFilter(ctx context.Context, raw any) (model.ProfessorFilter, error) { + var out model.ProfessorFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "ProfessorFilter", raw, &out) + return out, err +} + func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj any) (model.SectionFilter, error) { var it model.SectionFilter if obj == nil { @@ -7808,6 +7910,18 @@ func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj return it, nil } +// UnmarshalSectionFilter unmarshals raw into the SectionFilter input type, using the +// unmarshaler bound to ctx's request. Call it from a resolver to decode an input +// object that was not passed as a field argument. +// +// ctx must come from a gqlgen request; outside one there is no unmarshaler to use +// and the returned error says so. +func UnmarshalSectionFilter(ctx context.Context, raw any) (model.SectionFilter, error) { + var out model.SectionFilter + err := graphql.UnmarshalNamedInputFromContext(ctx, "SectionFilter", raw, &out) + return out, err +} + // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -7863,8 +7977,7 @@ func (ec *executionContext) _AcademicSession(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, academicSessionImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7893,14 +8006,10 @@ func (ec *executionContext) _AcademicSession(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -7911,8 +8020,7 @@ func (ec *executionContext) _Assistant(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, assistantImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7946,14 +8054,10 @@ func (ec *executionContext) _Assistant(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -7964,8 +8068,7 @@ func (ec *executionContext) _AstraBuilding(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, astraBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -7989,14 +8092,10 @@ func (ec *executionContext) _AstraBuilding(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8007,8 +8106,7 @@ func (ec *executionContext) _AstraDayEvents(ctx context.Context, sel ast.Selecti fields := graphql.CollectFields(ec.OperationContext, sel, astraDayEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8032,14 +8130,10 @@ func (ec *executionContext) _AstraDayEvents(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8050,8 +8144,7 @@ func (ec *executionContext) _AstraEvent(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, astraEventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8105,14 +8198,10 @@ func (ec *executionContext) _AstraEvent(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8123,8 +8212,7 @@ func (ec *executionContext) _AstraRoom(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, astraRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8148,14 +8236,10 @@ func (ec *executionContext) _AstraRoom(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8166,8 +8250,7 @@ func (ec *executionContext) _BuildingRooms(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, buildingRoomsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8201,14 +8284,10 @@ func (ec *executionContext) _BuildingRooms(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8219,8 +8298,7 @@ func (ec *executionContext) _CollectionRequirement(ctx context.Context, sel ast. fields := graphql.CollectFields(ec.OperationContext, sel, collectionRequirementImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8254,14 +8332,10 @@ func (ec *executionContext) _CollectionRequirement(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8272,8 +8346,7 @@ func (ec *executionContext) _CometCalendar(ctx context.Context, sel ast.Selectio fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8302,14 +8375,10 @@ func (ec *executionContext) _CometCalendar(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8320,8 +8389,7 @@ func (ec *executionContext) _CometCalendarBuilding(ctx context.Context, sel ast. fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8345,14 +8413,10 @@ func (ec *executionContext) _CometCalendarBuilding(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8363,8 +8427,7 @@ func (ec *executionContext) _CometCalendarRoom(ctx context.Context, sel ast.Sele fields := graphql.CollectFields(ec.OperationContext, sel, cometCalendarRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8388,14 +8451,10 @@ func (ec *executionContext) _CometCalendarRoom(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8406,8 +8465,7 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o fields := graphql.CollectFields(ec.OperationContext, sel, courseImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8488,43 +8546,11 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o atomic.AddUint32(&out.Invalids, 1) } case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Course_sections(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Course_sections(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "lecture_contact_hours": out.Values[i] = ec._Course_lecture_contact_hours(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -8559,14 +8585,10 @@ func (ec *executionContext) _Course(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8577,8 +8599,7 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob fields := graphql.CollectFields(ec.OperationContext, sel, eventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8667,14 +8688,10 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8685,8 +8702,7 @@ func (ec *executionContext) _Location(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, locationImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8715,14 +8731,10 @@ func (ec *executionContext) _Location(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8733,8 +8745,7 @@ func (ec *executionContext) _MazevoBuilding(ctx context.Context, sel ast.Selecti fields := graphql.CollectFields(ec.OperationContext, sel, mazevoBuildingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8758,14 +8769,10 @@ func (ec *executionContext) _MazevoBuilding(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8776,8 +8783,7 @@ func (ec *executionContext) _MazevoDayEvents(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, mazevoDayEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8801,14 +8807,10 @@ func (ec *executionContext) _MazevoDayEvents(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8819,8 +8821,7 @@ func (ec *executionContext) _MazevoEvent(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, mazevoEventImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8879,14 +8880,10 @@ func (ec *executionContext) _MazevoEvent(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8897,8 +8894,7 @@ func (ec *executionContext) _MazevoRoom(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, mazevoRoomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8922,14 +8918,10 @@ func (ec *executionContext) _MazevoRoom(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -8940,8 +8932,7 @@ func (ec *executionContext) _Meeting(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, meetingImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -8990,14 +8981,10 @@ func (ec *executionContext) _Meeting(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9008,8 +8995,7 @@ func (ec *executionContext) _MultiBuildingEvents(ctx context.Context, sel ast.Se fields := graphql.CollectFields(ec.OperationContext, sel, multiBuildingEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9033,14 +9019,10 @@ func (ec *executionContext) _MultiBuildingEvents(ctx context.Context, sel ast.Se return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9051,8 +9033,7 @@ func (ec *executionContext) _Office(ctx context.Context, sel ast.SelectionSet, o fields := graphql.CollectFields(ec.OperationContext, sel, officeImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9081,14 +9062,10 @@ func (ec *executionContext) _Office(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9099,8 +9076,7 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet fields := graphql.CollectFields(ec.OperationContext, sel, professorImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9156,43 +9132,11 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet atomic.AddUint32(&out.Invalids, 1) } case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Professor_sections(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Professor_sections(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9202,14 +9146,10 @@ func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9223,8 +9163,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -9235,313 +9174,89 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "__typename": out.Values[i] = graphql.MarshalString("Query") case "courses": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_courses(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_courses(ctx, field) + }) case "course": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_course(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_course(ctx, field) + }) case "professors": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_professors(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_professors(ctx, field) + }) case "professor": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_professor(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_professor(ctx, field) + }) case "sections": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_sections(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_sections(ctx, field) + }) case "section": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_section(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_section(ctx, field) + }) case "rooms": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_rooms(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_rooms(ctx, field) + }) case "cometCalendars": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_cometCalendars(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_cometCalendars(ctx, field) + }) case "cometCalendar": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_cometCalendar(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_cometCalendar(ctx, field) + }) case "events": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_events(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_events(ctx, field) + }) case "astraEvents": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEvents(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEvents(ctx, field) + }) case "astraEventsByBuilding": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEventsByBuilding(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEventsByBuilding(ctx, field) + }) case "astraEventsByRoom": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_astraEventsByRoom(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_astraEventsByRoom(ctx, field) + }) case "mazevoEvents": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_mazevoEvents(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + out.ResolveRootConcurrently(innerCtx, ec.OperationContext, i, + true, false, + func(ctx context.Context) graphql.Marshaler { + return ec._Query_mazevoEvents(ctx, field) + }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) @@ -9553,7 +9268,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - if out.Values[i] == graphql.RequiredNull { + if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: @@ -9565,14 +9280,10 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9583,8 +9294,7 @@ func (ec *executionContext) _Room(ctx context.Context, sel ast.SelectionSet, obj fields := graphql.CollectFields(ec.OperationContext, sel, roomImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9608,14 +9318,10 @@ func (ec *executionContext) _Room(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9626,8 +9332,7 @@ func (ec *executionContext) _RoomEvents(ctx context.Context, sel ast.SelectionSe fields := graphql.CollectFields(ec.OperationContext, sel, roomEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9651,14 +9356,10 @@ func (ec *executionContext) _RoomEvents(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9669,8 +9370,7 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, sectionImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9686,43 +9386,11 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, atomic.AddUint32(&out.Invalids, 1) } case "course_reference": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Section_course_reference(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Section_course_reference(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "section_corequisites": out.Values[i] = ec._Section_section_corequisites(ctx, field, obj) if out.Values[i] == graphql.RequiredNull { @@ -9734,43 +9402,11 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, atomic.AddUint32(&out.Invalids, 1) } case "professors": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Section_professors(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._Section_professors(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "teaching_assistants": out.Values[i] = ec._Section_teaching_assistants(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -9820,14 +9456,10 @@ func (ec *executionContext) _Section(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9838,50 +9470,17 @@ func (ec *executionContext) _SectionWithTime(ctx context.Context, sel ast.Select fields := graphql.CollectFields(ec.OperationContext, sel, sectionWithTimeImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("SectionWithTime") case "section": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._SectionWithTime_section(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.IsDeferred() { - deferredFieldSet.AddField(field) - fieldIndex := len(deferredFieldSet.Values) - 1 - deferredFieldSet.Concurrently(fieldIndex, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, deferredFieldSet) + out.ResolveConcurrently(ec.OperationContext, &deferred, i, + true, true, + func(ctx context.Context) graphql.Marshaler { + return ec._SectionWithTime_section(ctx, field, obj) }) - - for _, deferrable := range field.Deferrables { - view, ok := deferLabelToView[deferrable.Label] - if !ok { - view = deferredFieldSet.NewView() - deferLabelToView[deferrable.Label] = view - } - view.AddIndices(fieldIndex) - } - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "start_time": out.Values[i] = ec._SectionWithTime_start_time(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -9901,14 +9500,10 @@ func (ec *executionContext) _SectionWithTime(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9919,8 +9514,7 @@ func (ec *executionContext) _SingleBuildingEvents(ctx context.Context, sel ast.S fields := graphql.CollectFields(ec.OperationContext, sel, singleBuildingEventsImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -9944,14 +9538,10 @@ func (ec *executionContext) _SingleBuildingEvents(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -9962,8 +9552,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10002,14 +9591,10 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10020,8 +9605,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10055,14 +9639,10 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10073,8 +9653,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10118,14 +9697,10 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10136,8 +9711,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10181,14 +9755,10 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10199,8 +9769,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10244,14 +9813,10 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10262,8 +9827,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) + deferred := graphql.NewDeferredGroup(ctx) for i, field := range fields { switch field.Name { case "__typename": @@ -10332,14 +9896,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) + if n := len(deferred.Defers); n > 0 { + atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) + ec.ProcessDeferredGroup(deferred) + } return out } @@ -10350,9 +9910,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o func (ec *executionContext) marshalNAcademicSession2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAcademicSession(ctx context.Context, sel ast.SelectionSet, v *model.AcademicSession) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AcademicSession!") return graphql.Null } return ec._AcademicSession(ctx, sel, v) @@ -10376,9 +9934,7 @@ func (ec *executionContext) marshalNAssistant2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNAssistant2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAssistant(ctx context.Context, sel ast.SelectionSet, v *model.Assistant) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Assistant!") return graphql.Null } return ec._Assistant(ctx, sel, v) @@ -10402,9 +9958,7 @@ func (ec *executionContext) marshalNAstraBuilding2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNAstraBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraBuilding(ctx context.Context, sel ast.SelectionSet, v *model.AstraBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraBuilding!") return graphql.Null } return ec._AstraBuilding(ctx, sel, v) @@ -10428,9 +9982,7 @@ func (ec *executionContext) marshalNAstraEvent2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNAstraEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraEvent(ctx context.Context, sel ast.SelectionSet, v *model.AstraEvent) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraEvent!") return graphql.Null } return ec._AstraEvent(ctx, sel, v) @@ -10454,9 +10006,7 @@ func (ec *executionContext) marshalNAstraRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNAstraRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐAstraRoom(ctx context.Context, sel ast.SelectionSet, v *model.AstraRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "AstraRoom!") return graphql.Null } return ec._AstraRoom(ctx, sel, v) @@ -10471,9 +10021,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se _ = sel res := graphql.MarshalBoolean(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Boolean!") } return res } @@ -10496,9 +10044,7 @@ func (ec *executionContext) marshalNBuildingRooms2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNBuildingRooms2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐBuildingRooms(ctx context.Context, sel ast.SelectionSet, v *model.BuildingRooms) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "BuildingRooms!") return graphql.Null } return ec._BuildingRooms(ctx, sel, v) @@ -10522,9 +10068,7 @@ func (ec *executionContext) marshalNCometCalendar2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNCometCalendar2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendar(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendar) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendar!") return graphql.Null } return ec._CometCalendar(ctx, sel, v) @@ -10548,9 +10092,7 @@ func (ec *executionContext) marshalNCometCalendarBuilding2ᚕᚖgithubᚗcomᚋU func (ec *executionContext) marshalNCometCalendarBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendarBuilding(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendarBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendarBuilding!") return graphql.Null } return ec._CometCalendarBuilding(ctx, sel, v) @@ -10574,9 +10116,7 @@ func (ec *executionContext) marshalNCometCalendarRoom2ᚕᚖgithubᚗcomᚋUTDNe func (ec *executionContext) marshalNCometCalendarRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCometCalendarRoom(ctx context.Context, sel ast.SelectionSet, v *model.CometCalendarRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "CometCalendarRoom!") return graphql.Null } return ec._CometCalendarRoom(ctx, sel, v) @@ -10600,9 +10140,7 @@ func (ec *executionContext) marshalNCourse2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebu func (ec *executionContext) marshalNCourse2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐCourse(ctx context.Context, sel ast.SelectionSet, v *model.Course) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Course!") return graphql.Null } return ec._Course(ctx, sel, v) @@ -10617,9 +10155,7 @@ func (ec *executionContext) marshalNDateTime2timeᚐTime(ctx context.Context, se _ = sel res := graphql.MarshalTime(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "DateTime!") } return res } @@ -10642,9 +10178,7 @@ func (ec *executionContext) marshalNEvent2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebul func (ec *executionContext) marshalNEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐEvent(ctx context.Context, sel ast.SelectionSet, v *model.Event) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Event!") return graphql.Null } return ec._Event(ctx, sel, v) @@ -10659,9 +10193,7 @@ func (ec *executionContext) marshalNFloat642float64(ctx context.Context, sel ast _ = sel res := graphql.MarshalFloat(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Float64!") } return res } @@ -10675,9 +10207,7 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec _ = sel res := graphql.MarshalID(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "ID!") } return res } @@ -10691,18 +10221,14 @@ func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.Selec _ = sel res := graphql.MarshalInt32(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "Int!") } return res } func (ec *executionContext) marshalNLocation2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐLocation(ctx context.Context, sel ast.SelectionSet, v *model.Location) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Location!") return graphql.Null } return ec._Location(ctx, sel, v) @@ -10726,9 +10252,7 @@ func (ec *executionContext) marshalNMazevoBuilding2ᚕᚖgithubᚗcomᚋUTDNebul func (ec *executionContext) marshalNMazevoBuilding2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoBuilding(ctx context.Context, sel ast.SelectionSet, v *model.MazevoBuilding) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoBuilding!") return graphql.Null } return ec._MazevoBuilding(ctx, sel, v) @@ -10752,9 +10276,7 @@ func (ec *executionContext) marshalNMazevoEvent2ᚕᚖgithubᚗcomᚋUTDNebula func (ec *executionContext) marshalNMazevoEvent2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoEvent(ctx context.Context, sel ast.SelectionSet, v *model.MazevoEvent) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoEvent!") return graphql.Null } return ec._MazevoEvent(ctx, sel, v) @@ -10778,9 +10300,7 @@ func (ec *executionContext) marshalNMazevoRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNMazevoRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMazevoRoom(ctx context.Context, sel ast.SelectionSet, v *model.MazevoRoom) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "MazevoRoom!") return graphql.Null } return ec._MazevoRoom(ctx, sel, v) @@ -10804,9 +10324,7 @@ func (ec *executionContext) marshalNMeeting2ᚕᚖgithubᚗcomᚋUTDNebulaᚋneb func (ec *executionContext) marshalNMeeting2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐMeeting(ctx context.Context, sel ast.SelectionSet, v *model.Meeting) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Meeting!") return graphql.Null } return ec._Meeting(ctx, sel, v) @@ -10814,9 +10332,7 @@ func (ec *executionContext) marshalNMeeting2ᚖgithubᚗcomᚋUTDNebulaᚋnebula func (ec *executionContext) marshalNOffice2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐOffice(ctx context.Context, sel ast.SelectionSet, v *model.Office) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Office!") return graphql.Null } return ec._Office(ctx, sel, v) @@ -10840,9 +10356,7 @@ func (ec *executionContext) marshalNProfessor2ᚕᚖgithubᚗcomᚋUTDNebulaᚋn func (ec *executionContext) marshalNProfessor2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessor(ctx context.Context, sel ast.SelectionSet, v *model.Professor) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Professor!") return graphql.Null } return ec._Professor(ctx, sel, v) @@ -10866,9 +10380,7 @@ func (ec *executionContext) marshalNRoom2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebula func (ec *executionContext) marshalNRoom2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐRoom(ctx context.Context, sel ast.SelectionSet, v *model.Room) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Room!") return graphql.Null } return ec._Room(ctx, sel, v) @@ -10892,9 +10404,7 @@ func (ec *executionContext) marshalNRoomEvents2ᚕᚖgithubᚗcomᚋUTDNebulaᚋ func (ec *executionContext) marshalNRoomEvents2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐRoomEvents(ctx context.Context, sel ast.SelectionSet, v *model.RoomEvents) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "RoomEvents!") return graphql.Null } return ec._RoomEvents(ctx, sel, v) @@ -10918,9 +10428,7 @@ func (ec *executionContext) marshalNSection2ᚕᚖgithubᚗcomᚋUTDNebulaᚋneb func (ec *executionContext) marshalNSection2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSection(ctx context.Context, sel ast.SelectionSet, v *model.Section) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "Section!") return graphql.Null } return ec._Section(ctx, sel, v) @@ -10944,9 +10452,7 @@ func (ec *executionContext) marshalNSectionWithTime2ᚕᚖgithubᚗcomᚋUTDNebu func (ec *executionContext) marshalNSectionWithTime2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSectionWithTime(ctx context.Context, sel ast.SelectionSet, v *model.SectionWithTime) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "SectionWithTime!") return graphql.Null } return ec._SectionWithTime(ctx, sel, v) @@ -10970,9 +10476,7 @@ func (ec *executionContext) marshalNSingleBuildingEvents2ᚕᚖgithubᚗcomᚋUT func (ec *executionContext) marshalNSingleBuildingEvents2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐSingleBuildingEvents(ctx context.Context, sel ast.SelectionSet, v *model.SingleBuildingEvents) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "SingleBuildingEvents!") return graphql.Null } return ec._SingleBuildingEvents(ctx, sel, v) @@ -10987,9 +10491,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "String!") } return res } @@ -11052,9 +10554,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "__DirectiveLocation!") } return res } @@ -11117,6 +10617,14 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } +func (ec *executionContext) marshalN__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + graphql.AddInvalidNullError(ctx, "__Schema!") + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { return ec.___Type(ctx, sel, &v) } @@ -11139,9 +10647,7 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullError(ctx, "__Type!") return graphql.Null } return ec.___Type(ctx, sel, v) @@ -11156,9 +10662,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a _ = sel res := graphql.MarshalString(v) if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } + graphql.AddInvalidNullFromMarshaler(ctx, "__TypeKind!") } return res } @@ -11581,13 +11085,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/graphql/graph/schema.graphqls b/graphql/graph/schema.graphqls index 102dd2ba..7eb7f293 100644 --- a/graphql/graph/schema.graphqls +++ b/graphql/graph/schema.graphqls @@ -1,7 +1,9 @@ directive @goTag(key: String!, value: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +directive @goField(forceResolver: Boolean) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION scalar Any scalar Float64 scalar DateTime +scalar ObjectID type CollectionRequirement { type: String! name: String! @@ -24,7 +26,7 @@ type Course { prerequisites: CollectionRequirement corequisites: CollectionRequirement co_or_pre_requisites: CollectionRequirement - sections: [Section!]! + sections: [Section!]! @goField(forceResolver: true) lecture_contact_hours: String! laboratory_contact_hours: String! offering_frequency: String! @@ -61,7 +63,7 @@ type Professor { profile_uri: String! image_uri: String! office_hours: Any - sections: [Section!]! + sections: [Section!]! @goField(forceResolver: true) } input ProfessorFilter { email: String @goTag(key: "bson", value: "email,omitempty") @@ -98,10 +100,10 @@ type Meeting { type Section { _id: ID! section_number: String! - course_reference: Course! + course_reference: Course! @goField(forceResolver: true) section_corequisites: CollectionRequirement academic_session: AcademicSession! - professors: [Professor!]! + professors: [Professor!]! @goField(forceResolver: true) teaching_assistants: [Assistant!]! internal_class_number: String! instruction_mode: String! @@ -138,10 +140,10 @@ type SingleBuildingEvents { } type RoomEvents { room: String! - section_events: [SectionWithTime!]! + section_events: [SectionWithTime!]! } type SectionWithTime { - section: Section! + section: Section! @goField(forceResolver: true) start_time: String! end_time: String! } diff --git a/graphql/graph/schema.resolvers.go b/graphql/graph/schema.resolvers.go index f8160981..33d70e7b 100644 --- a/graphql/graph/schema.resolvers.go +++ b/graphql/graph/schema.resolvers.go @@ -1,22 +1,24 @@ package graph + // This file will be automatically regenerated based on the schema, any resolver + // implementations + // will be copied through when generating and any unknown code will be moved to the end. + // Code generated by github.com/99designs/gqlgen version v0.17.98 // Course returns CourseResolver implementation. -func (r *Resolver) Course() CourseResolver { return &courseResolver{r} } - + func (r *Resolver) Course() CourseResolver { return &courseResolver{r} } // Professor returns ProfessorResolver implementation. -func (r *Resolver) Professor() ProfessorResolver { return &professorResolver{r} } - + func (r *Resolver) Professor() ProfessorResolver { return &professorResolver{r} } // Query returns QueryResolver implementation. -func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } - + func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Section returns SectionResolver implementation. -func (r *Resolver) Section() SectionResolver { return §ionResolver{r} } - + func (r *Resolver) Section() SectionResolver { return §ionResolver{r} } // SectionWithTime returns SectionWithTimeResolver implementation. -func (r *Resolver) SectionWithTime() SectionWithTimeResolver { return §ionWithTimeResolver{r} } + func (r *Resolver) SectionWithTime() SectionWithTimeResolver { return §ionWithTimeResolver{r} } -type courseResolver struct{ *Resolver } -type professorResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } -type sectionResolver struct{ *Resolver } -type sectionWithTimeResolver struct{ *Resolver } +type ( + courseResolver struct{ *Resolver } + professorResolver struct{ *Resolver } + queryResolver struct{ *Resolver } + sectionResolver struct{ *Resolver } + sectionWithTimeResolver struct{ *Resolver } +) From 190e7d097cbf3e58b5c2efd7f67a4fe1a1a9204a Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 15:18:36 -0600 Subject: [PATCH 52/73] Switch to ObjectID instead of strings for ID --- graphql/gqlgen.yml | 2 +- graphql/graph/comet_calendar.resolvers.go | 11 +- graphql/graph/course.resolvers.go | 28 +- graphql/graph/events.resolvers.go | 12 +- graphql/graph/generated.go | 302 +++++------------ graphql/graph/model/db_models.go | 374 ---------------------- graphql/graph/model/db_models_test.go | 133 -------- graphql/graph/model/models.go | 72 +++++ graphql/graph/model/models_gen.go | 167 +++------- graphql/graph/model/scalars.go | 28 ++ graphql/graph/professor.resolvers.go | 32 +- graphql/graph/schema.graphqls | 82 +++-- graphql/graph/schema.resolvers.go | 25 +- graphql/graph/section.resolvers.go | 37 +-- graphql/loaders/professor.go | 42 +-- graphql/loaders/professor_test.go | 52 +-- graphql/loaders/section.go | 38 +-- 17 files changed, 373 insertions(+), 1064 deletions(-) delete mode 100644 graphql/graph/model/db_models.go delete mode 100644 graphql/graph/model/db_models_test.go create mode 100644 graphql/graph/model/models.go create mode 100644 graphql/graph/model/scalars.go diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml index 2e521ce5..d0818c49 100644 --- a/graphql/gqlgen.yml +++ b/graphql/gqlgen.yml @@ -121,7 +121,7 @@ call_argument_directives_with_null: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: -# - "graphql/graph/model" + - "./graph/model" # This section declares type mapping between the GraphQL and go type systems # diff --git a/graphql/graph/comet_calendar.resolvers.go b/graphql/graph/comet_calendar.resolvers.go index f597e1e6..1340ae3c 100644 --- a/graphql/graph/comet_calendar.resolvers.go +++ b/graphql/graph/comet_calendar.resolvers.go @@ -69,17 +69,14 @@ func (r *queryResolver) CometCalendars(ctx context.Context, filter *model.CometC } // CometCalendar is the resolver for the CometCalendar field. -func (r *queryResolver) CometCalendar(ctx context.Context, id string) (*model.CometCalendar, error) { +func (r *queryResolver) CometCalendar(ctx context.Context, id bson.ObjectID) (*model.CometCalendar, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - var calendar model.CometCalendar - err = r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}).Decode(&calendar) + var err error + + err = r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": id}).Decode(&calendar) if err != nil { if errors.Is(err, mongo.ErrNoDocuments) { return nil, fmt.Errorf("calendar not found: cannot find collection") diff --git a/graphql/graph/course.resolvers.go b/graphql/graph/course.resolvers.go index a087cb91..e2518dfb 100644 --- a/graphql/graph/course.resolvers.go +++ b/graphql/graph/course.resolvers.go @@ -18,10 +18,9 @@ func (r *queryResolver) Courses(ctx context.Context, filter *model.CourseFilter, defer cancel() var courses []*model.Course - var dbCourses []*model.DBCourse // Build the mongo query from the filter's struct - var courseQuery bson.M + courseQuery := bson.M{} if filter != nil { bsonBytes, err := bson.Marshal(filter) if err != nil { @@ -41,35 +40,28 @@ func (r *queryResolver) Courses(ctx context.Context, filter *model.CourseFilter, } defer cursor.Close(timeoutCtx) - if err = cursor.All(timeoutCtx, &dbCourses); err != nil { + // Unmarshal into courses + if err = cursor.All(timeoutCtx, &courses); err != nil { return nil, err } - // Transform Mongo course to GraphQL course - for _, dbCourse := range dbCourses { - courses = append(courses, model.TransformCourse(dbCourse)) - } - return courses, err } // Course is the resolver for the course field. -func (r *queryResolver) Course(ctx context.Context, id string) (*model.Course, error) { +func (r *queryResolver) Course(ctx context.Context, id bson.ObjectID) (*model.Course, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - - var dbCourse model.DBCourse - result := r.CourseCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(&dbCourse); err != nil { + var course model.Course + var err error + + result := r.CourseCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(&course); err != nil { return nil, err } - return model.TransformCourse(&dbCourse), err + return &course, err } // Sections is the resolver for the section field referenced from course diff --git a/graphql/graph/events.resolvers.go b/graphql/graph/events.resolvers.go index c9ed9187..07512843 100644 --- a/graphql/graph/events.resolvers.go +++ b/graphql/graph/events.resolvers.go @@ -6,6 +6,7 @@ import ( "time" "github.com/UTDNebula/nebula-api/graphql/graph/model" + "github.com/UTDNebula/nebula-api/graphql/loaders" "go.mongodb.org/mongo-driver/v2/bson" ) @@ -14,19 +15,18 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - var dbEvents model.DBMultiBuildingEvents var events *model.MultiBuildingEvents - err := r.EventCollection.FindOne(timeoutCtx, bson.M{"date": date}).Decode(&dbEvents) + err := r.EventCollection.FindOne(timeoutCtx, bson.M{"date": date}).Decode(events) if err != nil { return nil, err } - events = model.TransformMultiBuildingEvents(&dbEvents) if building == nil { return events, nil } - + + events = &model.MultiBuildingEvents{} for _, b := range events.Buildings { if b.Building == *building { if room == nil { @@ -46,5 +46,5 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin // Section implements [SectionWithTimeResolver]. func (r *sectionWithTimeResolver) Section(ctx context.Context, obj *model.SectionWithTime) (*model.Section, error) { - return r.Query().Section(ctx, obj.Section.ID) -} + return loaders.GetSection(ctx, obj.Section) +} \ No newline at end of file diff --git a/graphql/graph/generated.go b/graphql/graph/generated.go index a8adc1eb..70607936 100644 --- a/graphql/graph/generated.go +++ b/graphql/graph/generated.go @@ -18,6 +18,7 @@ import ( "github.com/UTDNebula/nebula-api/graphql/graph/model" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + "go.mongodb.org/mongo-driver/v2/bson" ) // region ***************************** api!.gotpl ***************************** @@ -200,12 +201,6 @@ type ComplexityRoot struct { Date func(childComplexity int) int } - Office struct { - Building func(childComplexity int) int - MapURI func(childComplexity int) int - Room func(childComplexity int) int - } - Professor struct { Email func(childComplexity int) int FirstName func(childComplexity int) int @@ -224,16 +219,16 @@ type ComplexityRoot struct { AstraEvents func(childComplexity int, date string) int AstraEventsByBuilding func(childComplexity int, date string, building string) int AstraEventsByRoom func(childComplexity int, date string, building string, room string) int - CometCalendar func(childComplexity int, id string) int + CometCalendar func(childComplexity int, id bson.ObjectID) int CometCalendars func(childComplexity int, filter *model.CometCalendarFilter, offset int32) int - Course func(childComplexity int, id string) int + Course func(childComplexity int, id bson.ObjectID) int Courses func(childComplexity int, filter *model.CourseFilter, offset int32) int Events func(childComplexity int, date string, building *string, room *string) int MazevoEvents func(childComplexity int, date string) int - Professor func(childComplexity int, id string) int + Professor func(childComplexity int, id bson.ObjectID) int Professors func(childComplexity int, filter *model.ProfessorFilter, offset int32) int Rooms func(childComplexity int) int - Section func(childComplexity int, id string) int + Section func(childComplexity int, id bson.ObjectID) int Sections func(childComplexity int, filter *model.SectionFilter, offset int32) int } @@ -288,14 +283,14 @@ type ProfessorResolver interface { } type QueryResolver interface { Courses(ctx context.Context, filter *model.CourseFilter, offset int32) ([]*model.Course, error) - Course(ctx context.Context, id string) (*model.Course, error) + Course(ctx context.Context, id bson.ObjectID) (*model.Course, error) Professors(ctx context.Context, filter *model.ProfessorFilter, offset int32) ([]*model.Professor, error) - Professor(ctx context.Context, id string) (*model.Professor, error) + Professor(ctx context.Context, id bson.ObjectID) (*model.Professor, error) Sections(ctx context.Context, filter *model.SectionFilter, offset int32) ([]*model.Section, error) - Section(ctx context.Context, id string) (*model.Section, error) + Section(ctx context.Context, id bson.ObjectID) (*model.Section, error) Rooms(ctx context.Context) ([]*model.BuildingRooms, error) CometCalendars(ctx context.Context, filter *model.CometCalendarFilter, offset int32) ([]*model.CometCalendar, error) - CometCalendar(ctx context.Context, id string) (*model.CometCalendar, error) + CometCalendar(ctx context.Context, id bson.ObjectID) (*model.CometCalendar, error) Events(ctx context.Context, date string, building *string, room *string) (model.EventResult, error) AstraEvents(ctx context.Context, date string) (*model.AstraDayEvents, error) AstraEventsByBuilding(ctx context.Context, date string, building string) (*model.AstraBuilding, error) @@ -943,25 +938,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.MultiBuildingEvents.Date(childComplexity), true - case "Office.building": - if e.ComplexityRoot.Office.Building == nil { - break - } - - return e.ComplexityRoot.Office.Building(childComplexity), true - case "Office.map_uri": - if e.ComplexityRoot.Office.MapURI == nil { - break - } - - return e.ComplexityRoot.Office.MapURI(childComplexity), true - case "Office.room": - if e.ComplexityRoot.Office.Room == nil { - break - } - - return e.ComplexityRoot.Office.Room(childComplexity), true - case "Professor.email": if e.ComplexityRoot.Professor.Email == nil { break @@ -1072,7 +1048,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.CometCalendar(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.CometCalendar(childComplexity, args["id"].(bson.ObjectID)), true case "Query.cometCalendars": if e.ComplexityRoot.Query.CometCalendars == nil { break @@ -1094,7 +1070,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Course(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Course(childComplexity, args["id"].(bson.ObjectID)), true case "Query.courses": if e.ComplexityRoot.Query.Courses == nil { break @@ -1139,7 +1115,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Professor(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Professor(childComplexity, args["id"].(bson.ObjectID)), true case "Query.professors": if e.ComplexityRoot.Query.Professors == nil { break @@ -1167,7 +1143,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.ComplexityRoot.Query.Section(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.Section(childComplexity, args["id"].(bson.ObjectID)), true case "Query.sections": if e.ComplexityRoot.Query.Sections == nil { break @@ -1727,18 +1703,6 @@ func (ec *executionContext) childFields_Meeting(ctx context.Context, field graph return nil, fmt.Errorf("no field named %q was found under type Meeting", field.Name) } -func (ec *executionContext) childFields_Office(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "building": - return ec.fieldContext_Office_building(ctx, field) - case "map_uri": - return ec.fieldContext_Office_map_uri(ctx, field) - case "room": - return ec.fieldContext_Office_room(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Office", field.Name) -} - func (ec *executionContext) childFields_Professor(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "_id": @@ -2043,8 +2007,8 @@ func (ec *executionContext) field_Query_cometCalendar_args(ctx context.Context, var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2079,8 +2043,8 @@ func (ec *executionContext) field_Query_course_args(ctx context.Context, rawArgs var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2159,8 +2123,8 @@ func (ec *executionContext) field_Query_professor_args(ctx context.Context, rawA var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -2195,8 +2159,8 @@ func (ec *executionContext) field_Query_section_args(ctx context.Context, rawArg var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (string, error) { - return ec.unmarshalNID2string(ctx, v) + func(ctx context.Context, v any) (bson.ObjectID, error) { + return ec.unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) }) if err != nil { return nil, err @@ -3016,15 +2980,15 @@ func (ec *executionContext) _CometCalendar__id(ctx context.Context, field graphq return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_CometCalendar__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "ID") + return graphql.NewScalarFieldContext("CometCalendar", field, false, false, "ObjectID") } func (ec *executionContext) _CometCalendar_date(ctx context.Context, field graphql.CollectedField, obj *model.CometCalendar) (ret graphql.Marshaler) { @@ -3204,15 +3168,15 @@ func (ec *executionContext) _Course__id(ctx context.Context, field graphql.Colle return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Course__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Course", field, false, false, "ID") + return graphql.NewScalarFieldContext("Course", field, false, false, "ObjectID") } func (ec *executionContext) _Course_subject_prefix(ctx context.Context, field graphql.CollectedField, obj *model.Course) (ret graphql.Marshaler) { @@ -3723,15 +3687,15 @@ func (ec *executionContext) _Event__id(ctx context.Context, field graphql.Collec return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Event__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Event", field, false, false, "ID") + return graphql.NewScalarFieldContext("Event", field, false, false, "ObjectID") } func (ec *executionContext) _Event_summary(ctx context.Context, field graphql.CollectedField, obj *model.Event) (ret graphql.Marshaler) { @@ -4722,75 +4686,6 @@ func (ec *executionContext) fieldContext_MultiBuildingEvents_buildings(_ context return fc, nil } -func (ec *executionContext) _Office_building(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_building(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Building, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_building(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, "String") -} - -func (ec *executionContext) _Office_map_uri(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_map_uri(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.MapURI, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_map_uri(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, "String") -} - -func (ec *executionContext) _Office_room(ctx context.Context, field graphql.CollectedField, obj *model.Office) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Office_room(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Room, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Office_room(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Office", field, false, false, "String") -} - func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -4803,15 +4698,15 @@ func (ec *executionContext) _Professor__id(ctx context.Context, field graphql.Co return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Professor__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Professor", field, false, false, "ID") + return graphql.NewScalarFieldContext("Professor", field, false, false, "ObjectID") } func (ec *executionContext) _Professor_first_name(ctx context.Context, field graphql.CollectedField, obj *model.Professor) (ret graphql.Marshaler) { @@ -4941,8 +4836,8 @@ func (ec *executionContext) _Professor_office(ctx context.Context, field graphql return obj.Office, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v *model.Office) graphql.Marshaler { - return ec.marshalNOffice2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐOffice(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v *model.Location) graphql.Marshaler { + return ec.marshalNLocation2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐLocation(ctx, selections, v) }, true, true, @@ -4955,7 +4850,7 @@ func (ec *executionContext) fieldContext_Professor_office(_ context.Context, fie IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_Office(ctx, field) + return ec.childFields_Location(ctx, field) }, } return fc, nil @@ -5116,7 +5011,7 @@ func (ec *executionContext) _Query_course(ctx context.Context, field graphql.Col }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Course(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Course(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Course) graphql.Marshaler { @@ -5204,7 +5099,7 @@ func (ec *executionContext) _Query_professor(ctx context.Context, field graphql. }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Professor(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Professor(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Professor) graphql.Marshaler { @@ -5292,7 +5187,7 @@ func (ec *executionContext) _Query_section(ctx context.Context, field graphql.Co }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().Section(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().Section(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.Section) graphql.Marshaler { @@ -5412,7 +5307,7 @@ func (ec *executionContext) _Query_cometCalendar(ctx context.Context, field grap }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().CometCalendar(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().CometCalendar(ctx, fc.Args["id"].(bson.ObjectID)) }, nil, func(ctx context.Context, selections ast.SelectionSet, v *model.CometCalendar) graphql.Marshaler { @@ -5855,15 +5750,15 @@ func (ec *executionContext) _Section__id(ctx context.Context, field graphql.Coll return obj.ID, nil }, nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNID2string(ctx, selections, v) + func(ctx context.Context, selections ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + return ec.marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, selections, v) }, true, true, ) } func (ec *executionContext) fieldContext_Section__id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Section", field, false, false, "ID") + return graphql.NewScalarFieldContext("Section", field, false, false, "ObjectID") } func (ec *executionContext) _Section_section_number(ctx context.Context, field graphql.CollectedField, obj *model.Section) (ret graphql.Marshaler) { @@ -7879,7 +7774,7 @@ func (ec *executionContext) unmarshalInputSectionFilter(ctx context.Context, obj it.SectionNumber = data case "course_reference": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("course_reference")) - data, err := ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx, v) if err != nil { return it, err } @@ -9027,49 +8922,6 @@ func (ec *executionContext) _MultiBuildingEvents(ctx context.Context, sel ast.Se return out } -var officeImplementors = []string{"Office"} - -func (ec *executionContext) _Office(ctx context.Context, sel ast.SelectionSet, obj *model.Office) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, officeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := graphql.NewDeferredGroup(ctx) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Office") - case "building": - out.Values[i] = ec._Office_building(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "map_uri": - out.Values[i] = ec._Office_map_uri(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "room": - out.Values[i] = ec._Office_room(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - if n := len(deferred.Defers); n > 0 { - atomic.AddInt32(&ec.Deferred, int32(min(n, math.MaxInt32))) - ec.ProcessDeferredGroup(deferred) - } - - return out -} - var professorImplementors = []string{"Professor"} func (ec *executionContext) _Professor(ctx context.Context, sel ast.SelectionSet, obj *model.Professor) graphql.Marshaler { @@ -10198,20 +10050,6 @@ func (ec *executionContext) marshalNFloat642float64(ctx context.Context, sel ast return res } -func (ec *executionContext) unmarshalNID2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := graphql.MarshalID(v) - if res == graphql.Null { - graphql.AddInvalidNullFromMarshaler(ctx, "ID!") - } - return res -} - func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v any) (int32, error) { res, err := graphql.UnmarshalInt32(v) return res, graphql.ErrorOnPath(ctx, err) @@ -10330,12 +10168,18 @@ func (ec *executionContext) marshalNMeeting2ᚖgithubᚗcomᚋUTDNebulaᚋnebula return ec._Meeting(ctx, sel, v) } -func (ec *executionContext) marshalNOffice2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐOffice(ctx context.Context, sel ast.SelectionSet, v *model.Office) graphql.Marshaler { - if v == nil { - graphql.AddInvalidNullError(ctx, "Office!") - return graphql.Null +func (ec *executionContext) unmarshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, v any) (bson.ObjectID, error) { + res, err := model.UnmarshalObjectID(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNObjectID2goᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, sel ast.SelectionSet, v bson.ObjectID) graphql.Marshaler { + _ = sel + res := model.MarshalObjectID(v) + if res == graphql.Null { + graphql.AddInvalidNullFromMarshaler(ctx, "ObjectID!") } - return ec._Office(ctx, sel, v) + return res } func (ec *executionContext) marshalNProfessor2ᚕᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessorᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Professor) graphql.Marshaler { @@ -10891,24 +10735,6 @@ func (ec *executionContext) marshalOFloat642ᚖfloat64(ctx context.Context, sel return res } -func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v any) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - _ = sel - _ = ctx - res := graphql.MarshalID(*v) - return res -} - func (ec *executionContext) unmarshalOInt2ᚕint32ᚄ(ctx context.Context, v any) ([]int32, error) { if v == nil { return nil, nil @@ -10951,6 +10777,24 @@ func (ec *executionContext) marshalOMazevoDayEvents2ᚖgithubᚗcomᚋUTDNebula return ec._MazevoDayEvents(ctx, sel, v) } +func (ec *executionContext) unmarshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, v any) (*bson.ObjectID, error) { + if v == nil { + return nil, nil + } + res, err := model.UnmarshalObjectID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOObjectID2ᚖgoᚗmongodbᚗorgᚋmongoᚑdriverᚋv2ᚋbsonᚐObjectID(ctx context.Context, sel ast.SelectionSet, v *bson.ObjectID) graphql.Marshaler { + if v == nil { + return graphql.Null + } + _ = sel + _ = ctx + res := model.MarshalObjectID(*v) + return res +} + func (ec *executionContext) marshalOProfessor2ᚖgithubᚗcomᚋUTDNebulaᚋnebulaᚑapiᚋgraphqlᚋgraphᚋmodelᚐProfessor(ctx context.Context, sel ast.SelectionSet, v *model.Professor) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/graphql/graph/model/db_models.go b/graphql/graph/model/db_models.go deleted file mode 100644 index 6fbc8eb1..00000000 --- a/graphql/graph/model/db_models.go +++ /dev/null @@ -1,374 +0,0 @@ -package model - -import ( - "time" - - "go.mongodb.org/mongo-driver/v2/bson" -) - -/* -These are the models that interact with the MongoDB -*/ - -type DBCollectionRequirement struct { - Type string `bson:"type"` - Name string `bson:"name"` - Required int32 `bson:"required"` - Options any `bson:"options"` -} - -func transformColReq(dbColReq *DBCollectionRequirement) *CollectionRequirement { - if dbColReq == nil { - return nil - } - return &CollectionRequirement{ - dbColReq.Type, - dbColReq.Name, - dbColReq.Required, - dbColReq.Options, - } -} - -// NOTE: For now, course on Mongo side is identical to course on GraphQL side -// However, in the near future, when we implement the REFERENCE RESOLVER, there will be diffs -type DBCourse struct { - ID bson.ObjectID `bson:"_id"` - SubjectPrefix string `bson:"subject_prefix"` - CourseNumber string `bson:"course_number"` - Title string `bson:"title"` - Description string `bson:"description"` - EnrollmentReqs string `bson:"enrollment_reqs"` - School string `bson:"school"` - CreditHours string `bson:"credit_hours"` - ClassLevel string `bson:"class_level"` - ActivityType string `bson:"activity_type"` - Grading string `bson:"grading"` - InternalCourseNumber string `bson:"internal_course_number"` - Prerequisites *DBCollectionRequirement `bson:"prerequisites"` - Corequisites *DBCollectionRequirement `bson:"corequisites"` - CoOrPreRequisites *DBCollectionRequirement `bson:"co_or_pre_requisites"` - Sections []bson.ObjectID `bson:"sections"` - LectureContactHours string `bson:"lecture_contact_hours"` - LaboratoryContactHours string `bson:"laboratory_contact_hours"` - OfferingFrequency string `bson:"offering_frequency"` - CatalogYear string `bson:"catalog_year"` - Attributes any `bson:"attributes"` -} - -// Transform the course object that interacts with Mongo to the course object that interacts with GraphQL -func TransformCourse(dbCourse *DBCourse) *Course { - if dbCourse == nil { - return nil - } - - sections := make([]*Section, len(dbCourse.Sections)) - for i, sectionID := range dbCourse.Sections { - sections[i] = &Section{ID: sectionID.Hex()} - } - - return &Course{ - dbCourse.ID.Hex(), - dbCourse.SubjectPrefix, - dbCourse.CourseNumber, - dbCourse.Title, - dbCourse.Description, - dbCourse.EnrollmentReqs, - dbCourse.School, - dbCourse.CreditHours, - dbCourse.ClassLevel, - dbCourse.ActivityType, - dbCourse.Grading, - dbCourse.InternalCourseNumber, - transformColReq(dbCourse.Prerequisites), - transformColReq(dbCourse.Corequisites), - transformColReq(dbCourse.Corequisites), - sections, - dbCourse.LectureContactHours, - dbCourse.LaboratoryContactHours, - dbCourse.OfferingFrequency, - dbCourse.CatalogYear, - dbCourse.Attributes, - } -} - -type DBOffice struct { - Building string `bson:"building"` - MapURI string `bson:"map_uri"` - Room string `bson:"room"` -} - -func TransformOffice(dbOffice *DBOffice) *Office { - if dbOffice == nil { - return nil - } - return &Office{ - dbOffice.Building, - dbOffice.MapURI, - dbOffice.Room, - } -} - -type DBProfessor struct { - ID bson.ObjectID `bson:"_id"` - FirstName string `bson:"first_name"` - LastName string `bson:"last_name"` - Titles []string `bson:"titles"` - Email string `bson:"email"` - PhoneNumber string `bson:"phone_number"` - Office *DBOffice `bson:"office"` - ProfileURI string `bson:"profile_uri"` - ImageURI string `bson:"image_uri"` - OfficeHours any `bson:"office_hours"` - Sections []bson.ObjectID `bson:"sections"` -} - -func TransformProfessor(dbProfessor *DBProfessor) *Professor { - if dbProfessor == nil { - return nil - } - - sections := make([]*Section, len(dbProfessor.Sections)) - for i, sectionID := range dbProfessor.Sections { - sections[i] = &Section{ID: sectionID.Hex()} - } - - return &Professor{ - dbProfessor.ID.Hex(), - dbProfessor.FirstName, - dbProfessor.LastName, - dbProfessor.Titles, - dbProfessor.Email, - dbProfessor.PhoneNumber, - TransformOffice(dbProfessor.Office), - dbProfessor.ProfileURI, - dbProfessor.ImageURI, - dbProfessor.OfficeHours, - sections, - } -} - -// --- Section DB Models and Transformers --- -type DBAcademicSession struct { - Name string `bson:"name"` - StartDate time.Time `bson:"start_date"` - EndDate time.Time `bson:"end_date"` -} - -type DBAssistant struct { - FirstName string `bson:"first_name"` - LastName string `bson:"last_name"` - Role string `bson:"role"` - Email string `bson:"email"` -} - -type DBLocation struct { - Building string `bson:"building"` - Room string `bson:"room"` - MapURI string `bson:"map_uri"` -} - -type DBMeeting struct { - StartDate time.Time `bson:"start_date"` - EndDate time.Time `bson:"end_date"` - MeetingDays []string `bson:"meeting_days"` - StartTime string `bson:"start_time"` - EndTime string `bson:"end_time"` - Modality string `bson:"modality"` - Location DBLocation `bson:"location"` -} - -type DBSection struct { - ID bson.ObjectID `bson:"_id"` - SectionNumber string `bson:"section_number"` - CourseReference bson.ObjectID `bson:"course_reference"` - SectionCorequisites *DBCollectionRequirement `bson:"section_corequisites"` - AcademicSession DBAcademicSession `bson:"academic_session"` - Professors []bson.ObjectID `bson:"professors"` - TeachingAssistants []DBAssistant `bson:"teaching_assistants"` - InternalClassNumber string `bson:"internal_class_number"` - InstructionMode string `bson:"instruction_mode"` - Meetings []DBMeeting `bson:"meetings"` - CoreFlags []string `bson:"core_flags"` - SyllabusURI string `bson:"syllabus_uri"` - GradeDistribution []int32 `bson:"grade_distribution"` - Attributes any `bson:"attributes"` -} - -func transformAcademicSession(dbSession *DBAcademicSession) *AcademicSession { - if dbSession == nil { - return nil - } - return &AcademicSession{ - Name: dbSession.Name, - StartDate: dbSession.StartDate, - EndDate: dbSession.EndDate, - } -} - -func transformAssistant(dbAssistant *DBAssistant) *Assistant { - if dbAssistant == nil { - return nil - } - return &Assistant{ - FirstName: dbAssistant.FirstName, - LastName: dbAssistant.LastName, - Role: dbAssistant.Role, - Email: dbAssistant.Email, - } -} - -func transformLocation(dbLocation *DBLocation) *Location { - if dbLocation == nil { - return nil - } - return &Location{ - Building: dbLocation.Building, - Room: dbLocation.Room, - MapURI: dbLocation.MapURI, - } -} - -func transformMeeting(dbMeeting *DBMeeting) *Meeting { - if dbMeeting == nil { - return nil - } - return &Meeting{ - StartDate: dbMeeting.StartDate, - EndDate: dbMeeting.EndDate, - MeetingDays: dbMeeting.MeetingDays, - StartTime: dbMeeting.StartTime, - EndTime: dbMeeting.EndTime, - Modality: dbMeeting.Modality, - Location: transformLocation(&dbMeeting.Location), - } -} - -// TransformSection converts a database section model into a GraphQL Section type. -func TransformSection(dbSection *DBSection) *Section { - if dbSection == nil { - return nil - } - - courseRef := &Course{ - ID: dbSection.CourseReference.Hex(), - } - - professors := make([]*Professor, len(dbSection.Professors)) - for i, professorID := range dbSection.Professors { - professors[i] = &Professor{ - ID: professorID.Hex(), - } - } - - assistants := make([]*Assistant, len(dbSection.TeachingAssistants)) - for i := range dbSection.TeachingAssistants { - assistants[i] = transformAssistant(&dbSection.TeachingAssistants[i]) - } - - meetings := make([]*Meeting, len(dbSection.Meetings)) - for i := range dbSection.Meetings { - meetings[i] = transformMeeting(&dbSection.Meetings[i]) - } - - return &Section{ - ID: dbSection.ID.Hex(), - SectionNumber: dbSection.SectionNumber, - CourseReference: courseRef, - SectionCorequisites: transformColReq(dbSection.SectionCorequisites), - AcademicSession: transformAcademicSession(&dbSection.AcademicSession), - Professors: professors, - TeachingAssistants: assistants, - InternalClassNumber: dbSection.InternalClassNumber, - InstructionMode: dbSection.InstructionMode, - Meetings: meetings, - CoreFlags: dbSection.CoreFlags, - SyllabusURI: dbSection.SyllabusURI, - GradeDistribution: dbSection.GradeDistribution, - Attributes: dbSection.Attributes, - } -} - -// Event DB Models since it references Section -type DBMultiBuildingEvents struct { - Date string `bson:"date" json:"date"` - Buildings []DBSingleBuildingEvents `bson:"buildings" json:"buildings"` -} - -type DBSingleBuildingEvents struct { - Building string `bson:"building" json:"building"` - Rooms []DBRoomEvents `bson:"rooms" json:"rooms"` -} - -type DBRoomEvents struct { - Room string `bson:"room" json:"room"` - Events []DBSectionWithTime `bson:"events" json:"events"` -} - -type DBSectionWithTime struct { - Section bson.ObjectID `bson:"section" json:"section"` - StartTime string `bson:"start_time" json:"start_time"` - EndTime string `bson:"end_time" json:"end_time"` -} - -func TransformSectionWithTime(dbSectionWithTime *DBSectionWithTime) *SectionWithTime { - if dbSectionWithTime == nil { - return nil - } - sectionWithID := Section{ - ID: dbSectionWithTime.Section.Hex(), - } - - return &SectionWithTime{ - Section: §ionWithID, - StartTime: dbSectionWithTime.StartTime, - EndTime: dbSectionWithTime.EndTime, - } -} - -func TransformRoomEvents(dbRoomEvents *DBRoomEvents) *RoomEvents { - if dbRoomEvents == nil { - return nil - } - - events := make([]*SectionWithTime, len(dbRoomEvents.Events)) - for i := range dbRoomEvents.Events { - events[i] = TransformSectionWithTime(&dbRoomEvents.Events[i]) - } - - return &RoomEvents{ - Room: dbRoomEvents.Room, - SectionEvents: events, - } -} - -func TransformSingleBuildingEvents(dbSingleBuildingEvents *DBSingleBuildingEvents) *SingleBuildingEvents { - if dbSingleBuildingEvents == nil { - return nil - } - - rooms := make([]*RoomEvents, len(dbSingleBuildingEvents.Rooms)) - for i := range dbSingleBuildingEvents.Rooms { - rooms[i] = TransformRoomEvents(&dbSingleBuildingEvents.Rooms[i]) - } - - return &SingleBuildingEvents{ - Building: dbSingleBuildingEvents.Building, - Rooms: rooms, - } -} - -func TransformMultiBuildingEvents(dbMultiBuildingEvents *DBMultiBuildingEvents) *MultiBuildingEvents { - if dbMultiBuildingEvents == nil { - return nil - } - - buildings := make([]*SingleBuildingEvents, len(dbMultiBuildingEvents.Buildings)) - for i := range dbMultiBuildingEvents.Buildings { - buildings[i] = TransformSingleBuildingEvents(&dbMultiBuildingEvents.Buildings[i]) - } - - return &MultiBuildingEvents{ - Date: dbMultiBuildingEvents.Date, - Buildings: buildings, - } -} diff --git a/graphql/graph/model/db_models_test.go b/graphql/graph/model/db_models_test.go deleted file mode 100644 index 6c96193a..00000000 --- a/graphql/graph/model/db_models_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package model - -import ( - "testing" - "time" - - "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/v2/bson" -) - -func TestTransformProfessor(t *testing.T) { - input := &DBProfessor{ - ID: bson.ObjectID{1}, - FirstName: "Ada", - LastName: "Example", - Titles: []string{"Professor", "Department Chair"}, - Email: "ada@example.com", - PhoneNumber: "555-0100", - Office: &DBOffice{Building: "ECSS", MapURI: "https://example.com/office", Room: "3.100"}, - ProfileURI: "https://example.com/profile", - ImageURI: "https://example.com/image", - OfficeHours: []string{"Monday 10:00-11:00"}, - Sections: []bson.ObjectID{{2}, {3}}, - } - want := &Professor{ - ID: "010000000000000000000000", - FirstName: "Ada", - LastName: "Example", - Titles: []string{"Professor", "Department Chair"}, - Email: "ada@example.com", - PhoneNumber: "555-0100", - Office: &Office{Building: "ECSS", MapURI: "https://example.com/office", Room: "3.100"}, - ProfileURI: "https://example.com/profile", - ImageURI: "https://example.com/image", - OfficeHours: []string{"Monday 10:00-11:00"}, - Sections: []*Section{ - {ID: "020000000000000000000000"}, - {ID: "030000000000000000000000"}, - }, - } - - if diff := cmp.Diff(want, TransformProfessor(input)); diff != "" { - t.Fatalf("TransformProfessor() mismatch (-want +got):\n%s", diff) - } -} - -func TestTransformProfessorNil(t *testing.T) { - if got := TransformProfessor(nil); got != nil { - t.Fatalf("TransformProfessor(nil) = %v, want nil", got) - } -} - -func TestTransformSection(t *testing.T) { - startDate := time.Date(2026, time.August, 17, 0, 0, 0, 0, time.UTC) - endDate := time.Date(2026, time.December, 11, 0, 0, 0, 0, time.UTC) - input := &DBSection{ - ID: bson.ObjectID{2}, - SectionNumber: "001", - CourseReference: bson.ObjectID{4}, - SectionCorequisites: &DBCollectionRequirement{ - Type: "all", Name: "Lab", Required: 1, Options: []string{"CS 1100"}, - }, - AcademicSession: DBAcademicSession{Name: "Fall 2026", StartDate: startDate, EndDate: endDate}, - Professors: []bson.ObjectID{{1}, {3}}, - TeachingAssistants: []DBAssistant{ - {FirstName: "Grace", LastName: "Example", Role: "TA", Email: "grace@example.com"}, - {FirstName: "Alan", LastName: "Sample", Role: "Tutor", Email: "alan@example.com"}, - }, - InternalClassNumber: "12345", - InstructionMode: "In Person", - Meetings: []DBMeeting{ - { - StartDate: startDate, EndDate: endDate, - MeetingDays: []string{"Monday", "Wednesday"}, StartTime: "10:00", EndTime: "11:15", - Modality: "Lecture", Location: DBLocation{Building: "ECSS", Room: "2.100", MapURI: "https://example.com/lecture"}, - }, - { - StartDate: startDate.AddDate(0, 0, 1), EndDate: endDate.AddDate(0, 0, -1), - MeetingDays: []string{"Tuesday"}, StartTime: "14:00", EndTime: "15:00", - Modality: "Lab", Location: DBLocation{Building: "ECSW", Room: "1.200", MapURI: "https://example.com/lab"}, - }, - }, - CoreFlags: []string{"030", "090"}, - SyllabusURI: "https://example.com/syllabus", - GradeDistribution: []int32{10, 8, 3, 1, 0}, - Attributes: map[string]string{"topic": "Computing"}, - } - want := &Section{ - ID: "020000000000000000000000", - SectionNumber: "001", - CourseReference: &Course{ID: "040000000000000000000000"}, - SectionCorequisites: &CollectionRequirement{ - Type: "all", Name: "Lab", Required: 1, Options: []string{"CS 1100"}, - }, - AcademicSession: &AcademicSession{Name: "Fall 2026", StartDate: startDate, EndDate: endDate}, - Professors: []*Professor{ - {ID: "010000000000000000000000"}, - {ID: "030000000000000000000000"}, - }, - TeachingAssistants: []*Assistant{ - {FirstName: "Grace", LastName: "Example", Role: "TA", Email: "grace@example.com"}, - {FirstName: "Alan", LastName: "Sample", Role: "Tutor", Email: "alan@example.com"}, - }, - InternalClassNumber: "12345", - InstructionMode: "In Person", - Meetings: []*Meeting{ - { - StartDate: startDate, EndDate: endDate, - MeetingDays: []string{"Monday", "Wednesday"}, StartTime: "10:00", EndTime: "11:15", - Modality: "Lecture", Location: &Location{Building: "ECSS", Room: "2.100", MapURI: "https://example.com/lecture"}, - }, - { - StartDate: startDate.AddDate(0, 0, 1), EndDate: endDate.AddDate(0, 0, -1), - MeetingDays: []string{"Tuesday"}, StartTime: "14:00", EndTime: "15:00", - Modality: "Lab", Location: &Location{Building: "ECSW", Room: "1.200", MapURI: "https://example.com/lab"}, - }, - }, - CoreFlags: []string{"030", "090"}, - SyllabusURI: "https://example.com/syllabus", - GradeDistribution: []int32{10, 8, 3, 1, 0}, - Attributes: map[string]string{"topic": "Computing"}, - } - - if diff := cmp.Diff(want, TransformSection(input)); diff != "" { - t.Fatalf("TransformSection() mismatch (-want +got):\n%s", diff) - } -} - -func TestTransformSectionNil(t *testing.T) { - if got := TransformSection(nil); got != nil { - t.Fatalf("TransformSection(nil) = %v, want nil", got) - } -} diff --git a/graphql/graph/model/models.go b/graphql/graph/model/models.go new file mode 100644 index 00000000..5f8ca1ef --- /dev/null +++ b/graphql/graph/model/models.go @@ -0,0 +1,72 @@ +package model + +import ( + "go.mongodb.org/mongo-driver/v2/bson" +) + +// Models that interact with MongoDB +// I.e., these models have ID reference to other models + +type Course struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + SubjectPrefix string `json:"subject_prefix" bson:"subject_prefix"` + CourseNumber string `json:"course_number" bson:"course_number"` + Title string `json:"title" bson:"title"` + Description string `json:"description" bson:"description"` + EnrollmentReqs string `json:"enrollment_reqs" bson:"enrollment_reqs"` + School string `json:"school" bson:"school"` + CreditHours string `json:"credit_hours" bson:"credit_hours"` + ClassLevel string `json:"class_level" bson:"class_level"` + ActivityType string `json:"activity_type" bson:"activity_type"` + Grading string `json:"grading" bson:"grading"` + InternalCourseNumber string `json:"internal_course_number" bson:"internal_course_number"` + Prerequisites *CollectionRequirement `json:"prerequisites,omitempty" bson:"prerequisites,omitempty"` + Corequisites *CollectionRequirement `json:"corequisites,omitempty" bson:"corequisites,omitempty"` + CoOrPreRequisites *CollectionRequirement `json:"co_or_pre_requisites,omitempty" bson:"co_or_pre_requisites,omitempty"` + Sections []bson.ObjectID `json:"sections" bson:"sections"` + LectureContactHours string `json:"lecture_contact_hours" bson:"lecture_contact_hours"` + LaboratoryContactHours string `json:"laboratory_contact_hours" bson:"laboratory_contact_hours"` + OfferingFrequency string `json:"offering_frequency" bson:"offering_frequency"` + CatalogYear string `json:"catalog_year" bson:"catalog_year"` + Attributes any `json:"attributes,omitempty" bson:"attributes,omitempty"` +} + + +type Professor struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + FirstName string `json:"first_name" bson:"first_name"` + LastName string `json:"last_name" bson:"last_name"` + Titles []string `json:"titles" bson:"titles"` + Email string `json:"email" bson:"email"` + PhoneNumber string `json:"phone_number" bson:"phone_number"` + Office *Location `json:"office" bson:"office"` + ProfileURI string `json:"profile_uri" bson:"profile_uri"` + ImageURI string `json:"image_uri" bson:"image_uri"` + OfficeHours any `json:"office_hours,omitempty" bson:"office_hours,omitempty"` + Sections []bson.ObjectID `json:"sections" bson:"sections"` +} + +type Section struct { + ID bson.ObjectID `json:"_id" bson:"_id"` + SectionNumber string `json:"section_number" bson:"section_number"` + CourseReference bson.ObjectID `json:"course_reference" bson:"course_reference"` + SectionCorequisites *CollectionRequirement `json:"section_corequisites,omitempty" bson:"section_corequisites,omitempty"` + AcademicSession *AcademicSession `json:"academic_session" bson:"academic_session"` + Professors []bson.ObjectID `json:"professors" bson:"professors"` + TeachingAssistants []*Assistant `json:"teaching_assistants" bson:"teaching_assistants"` + InternalClassNumber string `json:"internal_class_number" bson:"internal_class_number"` + InstructionMode string `json:"instruction_mode" bson:"instruction_mode"` + Meetings []*Meeting `json:"meetings" bson:"meetings"` + CoreFlags []string `json:"core_flags" bson:"core_flags"` + SyllabusURI string `json:"syllabus_uri" bson:"syllabus_uri"` + GradeDistribution []int32 `json:"grade_distribution,omitempty" bson:"grade_distribution,omitempty"` + Attributes any `json:"attributes,omitempty" bson:"attributes,omitempty"` +} + +type SectionWithTime struct { + Section bson.ObjectID `json:"section" bson:"section"` + StartTime string `json:"start_time" bson:"start_time"` + EndTime string `json:"end_time" bson:"end_time"` +} + +func (SectionWithTime) IsEventResult() {} \ No newline at end of file diff --git a/graphql/graph/model/models_gen.go b/graphql/graph/model/models_gen.go index afc6eb4b..430e62c9 100644 --- a/graphql/graph/model/models_gen.go +++ b/graphql/graph/model/models_gen.go @@ -4,6 +4,8 @@ package model import ( "time" + + "go.mongodb.org/mongo-driver/v2/bson" ) type EventResult interface { @@ -11,16 +13,16 @@ type EventResult interface { } type AcademicSession struct { - Name string `json:"name"` - StartDate time.Time `json:"start_date"` - EndDate time.Time `json:"end_date"` + Name string `json:"name" bson:"name"` + StartDate time.Time `json:"start_date" bson:"start_date"` + EndDate time.Time `json:"end_date" bson:"end_date"` } type Assistant struct { - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Role string `json:"role"` - Email string `json:"email"` + FirstName string `json:"first_name" bson:"first_name"` + LastName string `json:"last_name" bson:"last_name"` + Role string `json:"role" bson:"role"` + Email string `json:"email" bson:"email"` } type AstraBuilding struct { @@ -57,14 +59,14 @@ type BuildingRooms struct { } type CollectionRequirement struct { - Type string `json:"type"` - Name string `json:"name"` - Required int32 `json:"required"` - Options any `json:"options,omitempty"` + Type string `json:"type" bson:"type"` + Name string `json:"name" bson:"name"` + Required int32 `json:"required" bson:"required"` + Options any `json:"options,omitempty" bson:"options"` } type CometCalendar struct { - ID string `json:"_id" bson:"_id"` + ID bson.ObjectID `json:"_id" bson:"_id"` Date string `json:"date" bson:"date"` Buildings []*CometCalendarBuilding `json:"buildings" bson:"buildings"` } @@ -94,30 +96,6 @@ type CometCalendarRoomInput struct { Events []*EventInput `json:"events,omitempty"` } -type Course struct { - ID string `json:"_id"` - SubjectPrefix string `json:"subject_prefix"` - CourseNumber string `json:"course_number"` - Title string `json:"title"` - Description string `json:"description"` - EnrollmentReqs string `json:"enrollment_reqs"` - School string `json:"school"` - CreditHours string `json:"credit_hours"` - ClassLevel string `json:"class_level"` - ActivityType string `json:"activity_type"` - Grading string `json:"grading"` - InternalCourseNumber string `json:"internal_course_number"` - Prerequisites *CollectionRequirement `json:"prerequisites,omitempty"` - Corequisites *CollectionRequirement `json:"corequisites,omitempty"` - CoOrPreRequisites *CollectionRequirement `json:"co_or_pre_requisites,omitempty"` - Sections []*Section `json:"sections"` - LectureContactHours string `json:"lecture_contact_hours"` - LaboratoryContactHours string `json:"laboratory_contact_hours"` - OfferingFrequency string `json:"offering_frequency"` - CatalogYear string `json:"catalog_year"` - Attributes any `json:"attributes,omitempty"` -} - type CourseFilter struct { SubjectPrefix *string `json:"subject_prefix,omitempty" bson:"subject_prefix,omitempty"` CourseNumber *string `json:"course_number,omitempty" bson:"course_number,omitempty"` @@ -134,21 +112,21 @@ type CourseFilter struct { } type Event struct { - ID string `json:"_id" bson:"_id"` - Summary string `json:"summary" bson:"summary"` - Location string `json:"location" bson:"location"` - StartTime time.Time `json:"start_time" bson:"start_time"` - EndTime time.Time `json:"end_time" bson:"end_time"` - Description string `json:"description" bson:"description"` - EventType []string `json:"event_type" bson:"event_type"` - TargetAudience []string `json:"target_audience" bson:"target_audience"` - Topic []string `json:"topic" bson:"topic"` - EventTags []string `json:"event_tags" bson:"event_tags"` - EventWebsite string `json:"event_website" bson:"event_website"` - Department []string `json:"department" bson:"department"` - ContactName string `json:"contact_name" bson:"contact_name"` - ContactEmail string `json:"contact_email" bson:"contact_email"` - ContactPhoneNumber string `json:"contact_phone_number" bson:"contact_phone_number"` + ID bson.ObjectID `json:"_id" bson:"_id"` + Summary string `json:"summary" bson:"summary"` + Location string `json:"location" bson:"location"` + StartTime time.Time `json:"start_time" bson:"start_time"` + EndTime time.Time `json:"end_time" bson:"end_time"` + Description string `json:"description" bson:"description"` + EventType []string `json:"event_type" bson:"event_type"` + TargetAudience []string `json:"target_audience" bson:"target_audience"` + Topic []string `json:"topic" bson:"topic"` + EventTags []string `json:"event_tags" bson:"event_tags"` + EventWebsite string `json:"event_website" bson:"event_website"` + Department []string `json:"department" bson:"department"` + ContactName string `json:"contact_name" bson:"contact_name"` + ContactEmail string `json:"contact_email" bson:"contact_email"` + ContactPhoneNumber string `json:"contact_phone_number" bson:"contact_phone_number"` } type EventInput struct { @@ -163,9 +141,9 @@ type EventInput struct { } type Location struct { - Building string `json:"building"` - Room string `json:"room"` - MapURI string `json:"map_uri"` + Building string `json:"building" bson:"building"` + Room string `json:"room" bson:"room"` + MapURI string `json:"map_uri" bson:"map_uri"` } type MazevoBuilding struct { @@ -196,42 +174,22 @@ type MazevoRoom struct { } type Meeting struct { - StartDate time.Time `json:"start_date"` - EndDate time.Time `json:"end_date"` - MeetingDays []string `json:"meeting_days"` - StartTime string `json:"start_time"` - EndTime string `json:"end_time"` - Modality string `json:"modality"` - Location *Location `json:"location"` + StartDate time.Time `json:"start_date" bson:"start_date"` + EndDate time.Time `json:"end_date" bson:"end_date"` + MeetingDays []string `json:"meeting_days" bson:"meeting_days"` + StartTime string `json:"start_time" bson:"start_time"` + EndTime string `json:"end_time" bson:"end_time"` + Modality string `json:"modality" bson:"modality"` + Location *Location `json:"location" bson:"location"` } type MultiBuildingEvents struct { - Date string `json:"date"` - Buildings []*SingleBuildingEvents `json:"buildings"` + Date string `json:"date" bson:"date"` + Buildings []*SingleBuildingEvents `json:"buildings" bson:"buildings"` } func (MultiBuildingEvents) IsEventResult() {} -type Office struct { - Building string `json:"building"` - MapURI string `json:"map_uri"` - Room string `json:"room"` -} - -type Professor struct { - ID string `json:"_id"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Titles []string `json:"titles"` - Email string `json:"email"` - PhoneNumber string `json:"phone_number"` - Office *Office `json:"office"` - ProfileURI string `json:"profile_uri"` - ImageURI string `json:"image_uri"` - OfficeHours any `json:"office_hours,omitempty"` - Sections []*Section `json:"sections"` -} - type ProfessorFilter struct { Email *string `json:"email,omitempty" bson:"email,omitempty"` FirstName *string `json:"first_name,omitempty" bson:"first_name,omitempty"` @@ -249,48 +207,23 @@ type Room struct { } type RoomEvents struct { - Room string `json:"room"` - SectionEvents []*SectionWithTime `json:"section_events"` + Room string `json:"room" bson:"room"` + SectionEvents []*SectionWithTime `json:"section_events" bson:"events"` } func (RoomEvents) IsEventResult() {} -type Section struct { - ID string `json:"_id"` - SectionNumber string `json:"section_number"` - CourseReference *Course `json:"course_reference"` - SectionCorequisites *CollectionRequirement `json:"section_corequisites,omitempty"` - AcademicSession *AcademicSession `json:"academic_session"` - Professors []*Professor `json:"professors"` - TeachingAssistants []*Assistant `json:"teaching_assistants"` - InternalClassNumber string `json:"internal_class_number"` - InstructionMode string `json:"instruction_mode"` - Meetings []*Meeting `json:"meetings"` - CoreFlags []string `json:"core_flags"` - SyllabusURI string `json:"syllabus_uri"` - GradeDistribution []int32 `json:"grade_distribution,omitempty"` - Attributes any `json:"attributes,omitempty"` -} - type SectionFilter struct { - SectionNumber *string `json:"section_number,omitempty" bson:"section_number,omitempty"` - CourseReference *string `json:"course_reference,omitempty" bson:"course_reference,omitempty"` - InternalClassNumber *string `json:"internal_class_number,omitempty" bson:"internal_class_number,omitempty"` - InstructionMode *string `json:"instruction_mode,omitempty" bson:"instruction_mode,omitempty"` - SyllabusURI *string `json:"syllabus_uri,omitempty" bson:"syllabus_uri,omitempty"` + SectionNumber *string `json:"section_number,omitempty" bson:"section_number,omitempty"` + CourseReference *bson.ObjectID `json:"course_reference,omitempty" bson:"course_reference,omitempty"` + InternalClassNumber *string `json:"internal_class_number,omitempty" bson:"internal_class_number,omitempty"` + InstructionMode *string `json:"instruction_mode,omitempty" bson:"instruction_mode,omitempty"` + SyllabusURI *string `json:"syllabus_uri,omitempty" bson:"syllabus_uri,omitempty"` } -type SectionWithTime struct { - Section *Section `json:"section"` - StartTime string `json:"start_time"` - EndTime string `json:"end_time"` -} - -func (SectionWithTime) IsEventResult() {} - type SingleBuildingEvents struct { - Building string `json:"building"` - Rooms []*RoomEvents `json:"rooms"` + Building string `json:"building" bson:"building"` + Rooms []*RoomEvents `json:"rooms" bson:"rooms"` } func (SingleBuildingEvents) IsEventResult() {} diff --git a/graphql/graph/model/scalars.go b/graphql/graph/model/scalars.go new file mode 100644 index 00000000..9472cef9 --- /dev/null +++ b/graphql/graph/model/scalars.go @@ -0,0 +1,28 @@ +package model + +import ( + "fmt" + "io" + + "github.com/99designs/gqlgen/graphql" + "go.mongodb.org/mongo-driver/v2/bson" +) + +// This file is for custom marshaller and unmarshaller for types not from gqlgen + +// Marshaller for ObjectID scalar type +func MarshalObjectID(id bson.ObjectID) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + io.WriteString(w, fmt.Sprintf("%q", id.Hex())) + }) +} + +// Unmarshaller for ObjectID scalar type +func UnmarshalObjectID(v any) (bson.ObjectID, error) { + str, ok := v.(string) + if !ok { + return bson.NilObjectID, fmt.Errorf("ObjectID must be a string") + } + objectID, err := bson.ObjectIDFromHex(str) + return objectID, err +} \ No newline at end of file diff --git a/graphql/graph/professor.resolvers.go b/graphql/graph/professor.resolvers.go index bbc52183..62c0a251 100644 --- a/graphql/graph/professor.resolvers.go +++ b/graphql/graph/professor.resolvers.go @@ -17,9 +17,8 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF defer cancel() var professors []*model.Professor - var dbProfessors []*model.DBProfessor - - var professorQuery bson.M + + professorQuery := bson.M{} if filter != nil { bsonBytes, err := bson.Marshal(filter) if err != nil { @@ -28,9 +27,7 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF if err = bson.Unmarshal(bsonBytes, &professorQuery); err != nil { return nil, err } - } else { - professorQuery = bson.M{} // no filter - } + } paginate := options.Find().SetSkip(int64(offset)).SetLimit(configs.GetEnvLimit()) @@ -40,35 +37,26 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF } defer cursor.Close(timeoutCtx) - if err = cursor.All(timeoutCtx, &dbProfessors); err != nil { + if err = cursor.All(timeoutCtx, &professors); err != nil { return nil, err } - for _, dbProfessor := range dbProfessors { - professors = append(professors, model.TransformProfessor(dbProfessor)) - } - return professors, err } -func (r *queryResolver) Professor(ctx context.Context, id string) (*model.Professor, error) { +func (r *queryResolver) Professor(ctx context.Context, id bson.ObjectID) (*model.Professor, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } + professor := &model.Professor{} + var err error - dbProfessor := &model.DBProfessor{} - - result := r.ProfCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(dbProfessor); err != nil { + result := r.ProfCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(professor); err != nil { return nil, err } - return model.TransformProfessor(dbProfessor), err - + return professor, err } // Sections is the resolver for the section field referenced from professor diff --git a/graphql/graph/schema.graphqls b/graphql/graph/schema.graphqls index 7eb7f293..6269f400 100644 --- a/graphql/graph/schema.graphqls +++ b/graphql/graph/schema.graphqls @@ -5,13 +5,13 @@ scalar Float64 scalar DateTime scalar ObjectID type CollectionRequirement { - type: String! - name: String! - required: Int! - options: Any + type: String! @goTag(key: "bson", value: "type") + name: String! @goTag(key: "bson", value: "name") + required: Int! @goTag(key: "bson", value: "required") + options: Any @goTag(key: "bson", value: "options") } type Course { - _id: ID! + _id: ObjectID! subject_prefix: String! course_number: String! title: String! @@ -47,19 +47,15 @@ input CourseFilter { offering_frequency: String @goTag(key: "bson", value: "offering_frequency,omitempty") catalog_year: String @goTag(key: "bson", value: "catalog_year,omitempty") } -type Office { - building: String! - map_uri: String! - room: String! -} + type Professor { - _id: ID! + _id: ObjectID! first_name: String! last_name: String! titles: [String!]! email: String! phone_number: String! - office: Office! + office: Location! profile_uri: String! image_uri: String! office_hours: Any @@ -73,32 +69,32 @@ input ProfessorFilter { office_building: String @goTag(key: "bson", value: "office.building,omitempty") } type AcademicSession { - name: String! - start_date: DateTime! - end_date: DateTime! + name: String! @goTag(key: "bson", value: "name") + start_date: DateTime! @goTag(key: "bson", value: "start_date") + end_date: DateTime! @goTag(key: "bson", value: "end_date") } type Assistant { - first_name: String! - last_name: String! - role: String! - email: String! + first_name: String! @goTag(key: "bson", value: "first_name") + last_name: String! @goTag(key: "bson", value: "last_name") + role: String! @goTag(key: "bson", value: "role") + email: String! @goTag(key: "bson", value: "email") } type Location { - building: String! - room: String! - map_uri: String! + building: String! @goTag(key: "bson", value: "building") + room: String! @goTag(key: "bson", value: "room") + map_uri: String! @goTag(key: "bson", value: "map_uri") } type Meeting { - start_date: DateTime! - end_date: DateTime! - meeting_days: [String!]! - start_time: String! - end_time: String! - modality: String! - location: Location! + start_date: DateTime! @goTag(key: "bson", value: "start_date") + end_date: DateTime! @goTag(key: "bson", value: "end_date") + meeting_days: [String!]! @goTag(key: "bson", value: "meeting_days") + start_time: String! @goTag(key: "bson", value: "start_time") + end_time: String! @goTag(key: "bson", value: "end_time") + modality: String! @goTag(key: "bson", value: "modality") + location: Location! @goTag(key: "bson", value: "location") } type Section { - _id: ID! + _id: ObjectID! section_number: String! course_reference: Course! @goField(forceResolver: true) section_corequisites: CollectionRequirement @@ -115,7 +111,7 @@ type Section { } input SectionFilter { section_number: String @goTag(key: "bson", value: "section_number,omitempty") - course_reference: ID @goTag(key: "bson", value: "course_reference,omitempty") + course_reference: ObjectID @goTag(key: "bson", value: "course_reference,omitempty") internal_class_number: String @goTag(key: "bson", value: "internal_class_number,omitempty") instruction_mode: String @goTag(key: "bson", value: "instruction_mode,omitempty") syllabus_uri: String @goTag(key: "bson", value: "syllabus_uri,omitempty") @@ -131,16 +127,16 @@ type BuildingRooms { lon: Float64! @goTag(key: "bson", value: "lon") } type MultiBuildingEvents { - date: String! - buildings: [SingleBuildingEvents!]! + date: String! @goTag(key: "bson", value: "date") + buildings: [SingleBuildingEvents!]! @goTag(key: "bson", value: "buildings") } type SingleBuildingEvents { - building: String! - rooms: [RoomEvents!]! + building: String! @goTag(key: "bson", value: "building") + rooms: [RoomEvents!]! @goTag(key: "bson", value: "rooms") } type RoomEvents { - room: String! - section_events: [SectionWithTime!]! + room: String! @goTag(key: "bson", value: "room") + section_events: [SectionWithTime!]! @goTag(key: "bson", value: "events") } type SectionWithTime { section: Section! @goField(forceResolver: true) @@ -194,7 +190,7 @@ type MazevoDayEvents { buildings: [MazevoBuilding!]! @goTag(key: "bson", value: "buildings") } type Event { - _id: ID! @goTag(key: "bson", value: "_id") + _id: ObjectID! @goTag(key: "bson", value: "_id") summary: String! @goTag(key: "bson", value: "summary") location: String! @goTag(key: "bson", value: "location") start_time: DateTime! @goTag(key: "bson", value: "start_time") @@ -219,7 +215,7 @@ type CometCalendarBuilding { rooms: [CometCalendarRoom!]! @goTag(key: "bson", value: "rooms") } type CometCalendar { - _id: ID! @goTag(key: "bson", value: "_id") + _id: ObjectID! @goTag(key: "bson", value: "_id") date: String! @goTag(key: "bson", value: "date") buildings: [CometCalendarBuilding!]! @goTag(key: "bson", value: "buildings") } @@ -247,14 +243,14 @@ input EventInput { } type Query { courses(filter: CourseFilter, offset: Int! = 0): [Course!]! - course(id: ID!): Course + course(id: ObjectID!): Course professors(filter: ProfessorFilter, offset: Int! = 0): [Professor!]! - professor(id: ID!): Professor + professor(id: ObjectID!): Professor sections(filter: SectionFilter, offset: Int! = 0): [Section!]! - section(id: ID!): Section + section(id: ObjectID!): Section rooms: [BuildingRooms!]! cometCalendars(filter: CometCalendarFilter, offset: Int! = 0): [CometCalendar!]! - cometCalendar(id: ID!): CometCalendar + cometCalendar(id: ObjectID!): CometCalendar events(date: String!, building: String, room: String): EventResult astraEvents(date: String!): AstraDayEvents astraEventsByBuilding(date: String!, building: String!): AstraBuilding diff --git a/graphql/graph/schema.resolvers.go b/graphql/graph/schema.resolvers.go index 33d70e7b..c5099211 100644 --- a/graphql/graph/schema.resolvers.go +++ b/graphql/graph/schema.resolvers.go @@ -1,19 +1,26 @@ package graph - // This file will be automatically regenerated based on the schema, any resolver - // implementations - // will be copied through when generating and any unknown code will be moved to the end. - // Code generated by github.com/99designs/gqlgen version v0.17.98 + +import () + +// This file will be automatically regenerated based on the schema, any resolver +// implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.98 // Course returns CourseResolver implementation. - func (r *Resolver) Course() CourseResolver { return &courseResolver{r} } +func (r *Resolver) Course() CourseResolver { return &courseResolver{r} } + // Professor returns ProfessorResolver implementation. - func (r *Resolver) Professor() ProfessorResolver { return &professorResolver{r} } +func (r *Resolver) Professor() ProfessorResolver { return &professorResolver{r} } + // Query returns QueryResolver implementation. - func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + // Section returns SectionResolver implementation. - func (r *Resolver) Section() SectionResolver { return §ionResolver{r} } +func (r *Resolver) Section() SectionResolver { return §ionResolver{r} } + // SectionWithTime returns SectionWithTimeResolver implementation. - func (r *Resolver) SectionWithTime() SectionWithTimeResolver { return §ionWithTimeResolver{r} } +func (r *Resolver) SectionWithTime() SectionWithTimeResolver { return §ionWithTimeResolver{r} } type ( courseResolver struct{ *Resolver } diff --git a/graphql/graph/section.resolvers.go b/graphql/graph/section.resolvers.go index 10307ada..fd95c439 100644 --- a/graphql/graph/section.resolvers.go +++ b/graphql/graph/section.resolvers.go @@ -13,16 +13,11 @@ import ( ) // Sections is the resolver for the sections field. -func (r *queryResolver) Sections( - ctx context.Context, - filter *model.SectionFilter, - offset int32, -) ([]*model.Section, error) { +func (r *queryResolver) Sections(ctx context.Context, filter *model.SectionFilter, offset int32,) ([]*model.Section, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() var sections []*model.Section - var dbSections []*model.DBSection // building mongo query from filter (nil filter --> empty query --> return all) sectionQuery := bson.M{} @@ -47,42 +42,32 @@ func (r *queryResolver) Sections( defer cursor.Close(timeoutCtx) // Decode - if err := cursor.All(timeoutCtx, &dbSections); err != nil { + if err := cursor.All(timeoutCtx, §ions); err != nil { return nil, err } - for _, dbSection := range dbSections { - sections = append(sections, model.TransformSection(dbSection)) - } - return sections, nil } // Section is the resolver for the section field by ID. -func (r *queryResolver) Section(ctx context.Context, id string) (*model.Section, error) { +func (r *queryResolver) Section(ctx context.Context, id bson.ObjectID) (*model.Section, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - objectId, err := bson.ObjectIDFromHex(id) - if err != nil { - return nil, err - } - // decoding to a real value and not a nullptr - var dbSection model.DBSection - result := r.SectionCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}) - if err = result.Decode(&dbSection); err != nil { + var section model.Section + var err error + + result := r.SectionCollection.FindOne(timeoutCtx, bson.M{"_id": id}) + if err = result.Decode(§ion); err != nil { return nil, err } - return model.TransformSection(&dbSection), nil + return §ion, nil } -func (r *sectionResolver) CourseReference( - ctx context.Context, - obj *model.Section, -) (*model.Course, error) { - return r.Query().Course(ctx, obj.CourseReference.ID) +func (r *sectionResolver) CourseReference(ctx context.Context, obj *model.Section) (*model.Course, error) { + return r.Query().Course(ctx, obj.CourseReference) } func (r *sectionResolver) Professors(ctx context.Context, obj *model.Section) ([]*model.Professor, error) { diff --git a/graphql/loaders/professor.go b/graphql/loaders/professor.go index 0b896859..77ff186b 100644 --- a/graphql/loaders/professor.go +++ b/graphql/loaders/professor.go @@ -21,48 +21,36 @@ func (p *professorReader) getProfessors(ctx context.Context, professorIDs []bson } defer cursor.Close(ctx) - var dbProfessors []*model.DBProfessor - if err := cursor.All(ctx, &dbProfessors); err != nil { + var professors []*model.Professor + if err := cursor.All(ctx, &professors); err != nil { return nil, []error{err} } - professorMap := make(map[bson.ObjectID]*model.Professor, len(dbProfessors)) - for _, dbProfessor := range dbProfessors { - professorMap[dbProfessor.ID] = model.TransformProfessor(dbProfessor) + professorMap := make(map[bson.ObjectID]*model.Professor, len(professors)) + for _, professor := range professors { + professorMap[professor.ID] = professor } - professors := make([]*model.Professor, len(professorIDs)) + orderedProfessors := make([]*model.Professor, len(professorIDs)) errs := make([]error, len(professorIDs)) for i, id := range professorIDs { - professors[i] = professorMap[id] - if professors[i] == nil { + orderedProfessors[i] = professorMap[id] + if orderedProfessors[i] == nil { errs[i] = mongo.ErrNoDocuments } } - return professors, errs + return orderedProfessors, errs } // GetProfessor loads a professor from a reference that contains only its ID. -func GetProfessor(ctx context.Context, professorRef *model.Professor) (*model.Professor, error) { - professorID, err := bson.ObjectIDFromHex(professorRef.ID) - if err != nil { - return nil, err - } - - return For(ctx).ProfessorLoader.Load(ctx, professorID) +func GetProfessor(ctx context.Context, professorRef bson.ObjectID) (*model.Professor, error) { + loaders := For(ctx) + return loaders.ProfessorLoader.Load(ctx, professorRef) } // GetProfessors loads professors from references that contain only their IDs. -func GetProfessors(ctx context.Context, professorsRef []*model.Professor) ([]*model.Professor, error) { - professorIDs := make([]bson.ObjectID, len(professorsRef)) - for i, professor := range professorsRef { - professorID, err := bson.ObjectIDFromHex(professor.ID) - if err != nil { - return nil, err - } - professorIDs[i] = professorID - } - - return For(ctx).ProfessorLoader.LoadAll(ctx, professorIDs) +func GetProfessors(ctx context.Context, professorsRef []bson.ObjectID) ([]*model.Professor, error) { + loaders := For(ctx) + return loaders.ProfessorLoader.LoadAll(ctx, professorsRef) } diff --git a/graphql/loaders/professor_test.go b/graphql/loaders/professor_test.go index 93eea452..2e5f558a 100644 --- a/graphql/loaders/professor_test.go +++ b/graphql/loaders/professor_test.go @@ -1,33 +1,33 @@ package loaders import ( - "context" - "testing" + // "context" + // "testing" - "github.com/UTDNebula/nebula-api/graphql/graph/model" - "github.com/vikstrous/dataloadgen" - "go.mongodb.org/mongo-driver/v2/bson" + // "github.com/UTDNebula/nebula-api/graphql/graph/model" + // "github.com/vikstrous/dataloadgen" + // "go.mongodb.org/mongo-driver/v2/bson" ) -func TestGetProfessorsInvalidID(t *testing.T) { - // ID validation must finish before the loader can make a database query. - refs := []*model.Professor{{ID: bson.NewObjectID().Hex()}, {ID: "invalid"}} - if _, err := GetProfessors(context.Background(), refs); err == nil { - t.Fatal("expected invalid ID error") - } - if _, err := GetProfessor(context.Background(), refs[1]); err == nil { - t.Fatal("expected invalid ID error") - } -} +// func TestGetProfessorsInvalidID(t *testing.T) { +// // ID validation must finish before the loader can make a database query. +// refs := []*model.Professor{{ID: bson.NewObjectID()}, {ID: "invalid"}} +// if _, err := GetProfessors(context.Background(), refs); err == nil { +// t.Fatal("expected invalid ID error") +// } +// if _, err := GetProfessor(context.Background(), refs[1]); err == nil { +// t.Fatal("expected invalid ID error") +// } +// } -func TestGetProfessorsEmpty(t *testing.T) { - loader := dataloadgen.NewLoader(func(context.Context, []bson.ObjectID) ([]*model.Professor, []error) { - t.Error("empty references must not query the database") - return nil, nil - }) - ctx := context.WithValue(context.Background(), loadersKey, &Loaders{ProfessorLoader: loader}) - professors, err := GetProfessors(ctx, nil) - if err != nil || professors == nil || len(professors) != 0 { - t.Fatalf("expected empty list, got %v, %v", professors, err) - } -} +// func TestGetProfessorsEmpty(t *testing.T) { +// loader := dataloadgen.NewLoader(func(context.Context, []bson.ObjectID) ([]*model.Professor, []error) { +// t.Error("empty references must not query the database") +// return nil, nil +// }) +// ctx := context.WithValue(context.Background(), loadersKey, &Loaders{ProfessorLoader: loader}) +// professors, err := GetProfessors(ctx, nil) +// if err != nil || professors == nil || len(professors) != 0 { +// t.Fatalf("expected empty list, got %v, %v", professors, err) +// } +// } diff --git a/graphql/loaders/section.go b/graphql/loaders/section.go index 7e36a827..fb41e175 100644 --- a/graphql/loaders/section.go +++ b/graphql/loaders/section.go @@ -23,24 +23,24 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec defer cursor.Close(ctx) // Decode - var dbSections []*model.DBSection - if err := cursor.All(ctx, &dbSections); err != nil { + var sections []*model.Section + if err := cursor.All(ctx, §ions); err != nil { return nil, []error{err} } // $in does not return in order of given sectionIDs // so we order with map. - sectionMap := make(map[bson.ObjectID]*model.Section, len(dbSections)) - for _, dbSection := range dbSections { - sectionMap[dbSection.ID] = model.TransformSection(dbSection) + sectionMap := make(map[bson.ObjectID]*model.Section, len(sections)) + for _, section := range sections { + sectionMap[section.ID] = section } - sections := make([]*model.Section, len(sectionIDs)) + orderedSections := make([]*model.Section, len(sectionIDs)) for i, ID := range sectionIDs { - sections[i] = sectionMap[ID] + orderedSections[i] = sectionMap[ID] } - return sections, nil + return orderedSections, nil } // For convenience in resolvers @@ -48,29 +48,15 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec // GetSection returns single section by id efficiently // Note that sectionRef contains only its ObjectID. // All other fields in sectionRef are empty. -func GetSection(ctx context.Context, sectionRef *model.Section) (*model.Section, error) { - sectionID, err := bson.ObjectIDFromHex(sectionRef.ID) - if err != nil { - return nil, err - } - +func GetSection(ctx context.Context, sectionRef bson.ObjectID) (*model.Section, error) { loaders := For(ctx) - return loaders.SectionLoader.Load(ctx, sectionID) + return loaders.SectionLoader.Load(ctx, sectionRef) } // GetSections returns many sections by ids efficiently // Note that sectionsRef contains only the sections' ObjectID. // All other fields of each section in sectionsRef are empty. -func GetSections(ctx context.Context, sectionsRef []*model.Section) ([]*model.Section, error) { - sectionIDs := make([]bson.ObjectID, len(sectionsRef)) - for i, section := range sectionsRef { - sectionID, err := bson.ObjectIDFromHex(section.ID) - if err != nil { - return nil, err - } - sectionIDs[i] = sectionID - } - +func GetSections(ctx context.Context, sectionsRef []bson.ObjectID) ([]*model.Section, error) { loaders := For(ctx) - return loaders.SectionLoader.LoadAll(ctx, sectionIDs) + return loaders.SectionLoader.LoadAll(ctx, sectionsRef) } From 5dc7f09d8f48d968f9d57d061e2c3e007be6ea01 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 15:29:21 -0600 Subject: [PATCH 53/73] Format code --- graphql/graph/course.resolvers.go | 2 +- graphql/graph/events.resolvers.go | 4 +-- graphql/graph/model/models.go | 37 ++++++++++++++-------------- graphql/graph/model/scalars.go | 2 +- graphql/graph/professor.resolvers.go | 4 +-- graphql/graph/schema.resolvers.go | 2 -- graphql/graph/section.resolvers.go | 2 +- graphql/loaders/professor.go | 2 +- graphql/loaders/professor_test.go | 12 ++++----- 9 files changed, 31 insertions(+), 36 deletions(-) diff --git a/graphql/graph/course.resolvers.go b/graphql/graph/course.resolvers.go index e2518dfb..7684ec4a 100644 --- a/graphql/graph/course.resolvers.go +++ b/graphql/graph/course.resolvers.go @@ -55,7 +55,7 @@ func (r *queryResolver) Course(ctx context.Context, id bson.ObjectID) (*model.Co var course model.Course var err error - + result := r.CourseCollection.FindOne(timeoutCtx, bson.M{"_id": id}) if err = result.Decode(&course); err != nil { return nil, err diff --git a/graphql/graph/events.resolvers.go b/graphql/graph/events.resolvers.go index 07512843..f01f4e56 100644 --- a/graphql/graph/events.resolvers.go +++ b/graphql/graph/events.resolvers.go @@ -25,7 +25,7 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin if building == nil { return events, nil } - + events = &model.MultiBuildingEvents{} for _, b := range events.Buildings { if b.Building == *building { @@ -47,4 +47,4 @@ func (r *queryResolver) Events(ctx context.Context, date string, building *strin // Section implements [SectionWithTimeResolver]. func (r *sectionWithTimeResolver) Section(ctx context.Context, obj *model.SectionWithTime) (*model.Section, error) { return loaders.GetSection(ctx, obj.Section) -} \ No newline at end of file +} diff --git a/graphql/graph/model/models.go b/graphql/graph/model/models.go index 5f8ca1ef..3880dd68 100644 --- a/graphql/graph/model/models.go +++ b/graphql/graph/model/models.go @@ -8,7 +8,7 @@ import ( // I.e., these models have ID reference to other models type Course struct { - ID bson.ObjectID `json:"_id" bson:"_id"` + ID bson.ObjectID `json:"_id" bson:"_id"` SubjectPrefix string `json:"subject_prefix" bson:"subject_prefix"` CourseNumber string `json:"course_number" bson:"course_number"` Title string `json:"title" bson:"title"` @@ -23,7 +23,7 @@ type Course struct { Prerequisites *CollectionRequirement `json:"prerequisites,omitempty" bson:"prerequisites,omitempty"` Corequisites *CollectionRequirement `json:"corequisites,omitempty" bson:"corequisites,omitempty"` CoOrPreRequisites *CollectionRequirement `json:"co_or_pre_requisites,omitempty" bson:"co_or_pre_requisites,omitempty"` - Sections []bson.ObjectID `json:"sections" bson:"sections"` + Sections []bson.ObjectID `json:"sections" bson:"sections"` LectureContactHours string `json:"lecture_contact_hours" bson:"lecture_contact_hours"` LaboratoryContactHours string `json:"laboratory_contact_hours" bson:"laboratory_contact_hours"` OfferingFrequency string `json:"offering_frequency" bson:"offering_frequency"` @@ -31,28 +31,27 @@ type Course struct { Attributes any `json:"attributes,omitempty" bson:"attributes,omitempty"` } - type Professor struct { - ID bson.ObjectID `json:"_id" bson:"_id"` - FirstName string `json:"first_name" bson:"first_name"` - LastName string `json:"last_name" bson:"last_name"` - Titles []string `json:"titles" bson:"titles"` - Email string `json:"email" bson:"email"` - PhoneNumber string `json:"phone_number" bson:"phone_number"` - Office *Location `json:"office" bson:"office"` - ProfileURI string `json:"profile_uri" bson:"profile_uri"` - ImageURI string `json:"image_uri" bson:"image_uri"` - OfficeHours any `json:"office_hours,omitempty" bson:"office_hours,omitempty"` + ID bson.ObjectID `json:"_id" bson:"_id"` + FirstName string `json:"first_name" bson:"first_name"` + LastName string `json:"last_name" bson:"last_name"` + Titles []string `json:"titles" bson:"titles"` + Email string `json:"email" bson:"email"` + PhoneNumber string `json:"phone_number" bson:"phone_number"` + Office *Location `json:"office" bson:"office"` + ProfileURI string `json:"profile_uri" bson:"profile_uri"` + ImageURI string `json:"image_uri" bson:"image_uri"` + OfficeHours any `json:"office_hours,omitempty" bson:"office_hours,omitempty"` Sections []bson.ObjectID `json:"sections" bson:"sections"` } type Section struct { - ID bson.ObjectID `json:"_id" bson:"_id"` + ID bson.ObjectID `json:"_id" bson:"_id"` SectionNumber string `json:"section_number" bson:"section_number"` - CourseReference bson.ObjectID `json:"course_reference" bson:"course_reference"` + CourseReference bson.ObjectID `json:"course_reference" bson:"course_reference"` SectionCorequisites *CollectionRequirement `json:"section_corequisites,omitempty" bson:"section_corequisites,omitempty"` AcademicSession *AcademicSession `json:"academic_session" bson:"academic_session"` - Professors []bson.ObjectID `json:"professors" bson:"professors"` + Professors []bson.ObjectID `json:"professors" bson:"professors"` TeachingAssistants []*Assistant `json:"teaching_assistants" bson:"teaching_assistants"` InternalClassNumber string `json:"internal_class_number" bson:"internal_class_number"` InstructionMode string `json:"instruction_mode" bson:"instruction_mode"` @@ -65,8 +64,8 @@ type Section struct { type SectionWithTime struct { Section bson.ObjectID `json:"section" bson:"section"` - StartTime string `json:"start_time" bson:"start_time"` - EndTime string `json:"end_time" bson:"end_time"` + StartTime string `json:"start_time" bson:"start_time"` + EndTime string `json:"end_time" bson:"end_time"` } -func (SectionWithTime) IsEventResult() {} \ No newline at end of file +func (SectionWithTime) IsEventResult() {} diff --git a/graphql/graph/model/scalars.go b/graphql/graph/model/scalars.go index 9472cef9..d7e53528 100644 --- a/graphql/graph/model/scalars.go +++ b/graphql/graph/model/scalars.go @@ -25,4 +25,4 @@ func UnmarshalObjectID(v any) (bson.ObjectID, error) { } objectID, err := bson.ObjectIDFromHex(str) return objectID, err -} \ No newline at end of file +} diff --git a/graphql/graph/professor.resolvers.go b/graphql/graph/professor.resolvers.go index 62c0a251..b5e63969 100644 --- a/graphql/graph/professor.resolvers.go +++ b/graphql/graph/professor.resolvers.go @@ -17,7 +17,7 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF defer cancel() var professors []*model.Professor - + professorQuery := bson.M{} if filter != nil { bsonBytes, err := bson.Marshal(filter) @@ -27,7 +27,7 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF if err = bson.Unmarshal(bsonBytes, &professorQuery); err != nil { return nil, err } - } + } paginate := options.Find().SetSkip(int64(offset)).SetLimit(configs.GetEnvLimit()) diff --git a/graphql/graph/schema.resolvers.go b/graphql/graph/schema.resolvers.go index c5099211..94f9a668 100644 --- a/graphql/graph/schema.resolvers.go +++ b/graphql/graph/schema.resolvers.go @@ -1,7 +1,5 @@ package graph -import () - // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. diff --git a/graphql/graph/section.resolvers.go b/graphql/graph/section.resolvers.go index fd95c439..2f1ffa99 100644 --- a/graphql/graph/section.resolvers.go +++ b/graphql/graph/section.resolvers.go @@ -13,7 +13,7 @@ import ( ) // Sections is the resolver for the sections field. -func (r *queryResolver) Sections(ctx context.Context, filter *model.SectionFilter, offset int32,) ([]*model.Section, error) { +func (r *queryResolver) Sections(ctx context.Context, filter *model.SectionFilter, offset int32) ([]*model.Section, error) { timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() diff --git a/graphql/loaders/professor.go b/graphql/loaders/professor.go index 77ff186b..c9b6e816 100644 --- a/graphql/loaders/professor.go +++ b/graphql/loaders/professor.go @@ -51,6 +51,6 @@ func GetProfessor(ctx context.Context, professorRef bson.ObjectID) (*model.Profe // GetProfessors loads professors from references that contain only their IDs. func GetProfessors(ctx context.Context, professorsRef []bson.ObjectID) ([]*model.Professor, error) { - loaders := For(ctx) + loaders := For(ctx) return loaders.ProfessorLoader.LoadAll(ctx, professorsRef) } diff --git a/graphql/loaders/professor_test.go b/graphql/loaders/professor_test.go index 2e5f558a..4eb4a363 100644 --- a/graphql/loaders/professor_test.go +++ b/graphql/loaders/professor_test.go @@ -1,13 +1,11 @@ package loaders -import ( - // "context" - // "testing" +// "context" +// "testing" - // "github.com/UTDNebula/nebula-api/graphql/graph/model" - // "github.com/vikstrous/dataloadgen" - // "go.mongodb.org/mongo-driver/v2/bson" -) +// "github.com/UTDNebula/nebula-api/graphql/graph/model" +// "github.com/vikstrous/dataloadgen" +// "go.mongodb.org/mongo-driver/v2/bson" // func TestGetProfessorsInvalidID(t *testing.T) { // // ID validation must finish before the loader can make a database query. From 7766245bb9564d2159404b51e1d45d1d11d2342e Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 22:05:45 -0600 Subject: [PATCH 54/73] Remove unnecessary tests and comments --- graphql/loaders/professor_test.go | 31 ------------------------------- graphql/loaders/section.go | 4 ---- 2 files changed, 35 deletions(-) delete mode 100644 graphql/loaders/professor_test.go diff --git a/graphql/loaders/professor_test.go b/graphql/loaders/professor_test.go deleted file mode 100644 index 4eb4a363..00000000 --- a/graphql/loaders/professor_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package loaders - -// "context" -// "testing" - -// "github.com/UTDNebula/nebula-api/graphql/graph/model" -// "github.com/vikstrous/dataloadgen" -// "go.mongodb.org/mongo-driver/v2/bson" - -// func TestGetProfessorsInvalidID(t *testing.T) { -// // ID validation must finish before the loader can make a database query. -// refs := []*model.Professor{{ID: bson.NewObjectID()}, {ID: "invalid"}} -// if _, err := GetProfessors(context.Background(), refs); err == nil { -// t.Fatal("expected invalid ID error") -// } -// if _, err := GetProfessor(context.Background(), refs[1]); err == nil { -// t.Fatal("expected invalid ID error") -// } -// } - -// func TestGetProfessorsEmpty(t *testing.T) { -// loader := dataloadgen.NewLoader(func(context.Context, []bson.ObjectID) ([]*model.Professor, []error) { -// t.Error("empty references must not query the database") -// return nil, nil -// }) -// ctx := context.WithValue(context.Background(), loadersKey, &Loaders{ProfessorLoader: loader}) -// professors, err := GetProfessors(ctx, nil) -// if err != nil || professors == nil || len(professors) != 0 { -// t.Fatalf("expected empty list, got %v, %v", professors, err) -// } -// } diff --git a/graphql/loaders/section.go b/graphql/loaders/section.go index fb41e175..aab4e31f 100644 --- a/graphql/loaders/section.go +++ b/graphql/loaders/section.go @@ -46,16 +46,12 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec // For convenience in resolvers // GetSection returns single section by id efficiently -// Note that sectionRef contains only its ObjectID. -// All other fields in sectionRef are empty. func GetSection(ctx context.Context, sectionRef bson.ObjectID) (*model.Section, error) { loaders := For(ctx) return loaders.SectionLoader.Load(ctx, sectionRef) } // GetSections returns many sections by ids efficiently -// Note that sectionsRef contains only the sections' ObjectID. -// All other fields of each section in sectionsRef are empty. func GetSections(ctx context.Context, sectionsRef []bson.ObjectID) ([]*model.Section, error) { loaders := For(ctx) return loaders.SectionLoader.LoadAll(ctx, sectionsRef) From c58164514bd6511bf5474f2ca0e70ee15cdebf26 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 22:56:01 -0600 Subject: [PATCH 55/73] Add some error handling for section dataloader --- graphql/loaders/section.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphql/loaders/section.go b/graphql/loaders/section.go index aab4e31f..0d806079 100644 --- a/graphql/loaders/section.go +++ b/graphql/loaders/section.go @@ -36,11 +36,15 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec } orderedSections := make([]*model.Section, len(sectionIDs)) + errs := make([]error, len(sectionIDs)) for i, ID := range sectionIDs { orderedSections[i] = sectionMap[ID] + if orderedSections[i] == nil { + errs[i] = mongo.ErrNoDocuments + } } - return orderedSections, nil + return orderedSections, errs } // For convenience in resolvers From 896cfa8345837944937a1da2c9ab3e6c32120e05 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 23:53:36 -0600 Subject: [PATCH 56/73] Switch to using go tool for gqlgen generate --- build.bat | 4 ++-- go.mod | 3 +++ go.sum | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.bat b/build.bat index 13febd06..f9a708f7 100644 --- a/build.bat +++ b/build.bat @@ -156,12 +156,12 @@ exit /b 0 :generate echo Generating GraphQL execution layer... pushd graphql -go get github.com/99designs/gqlgen@latest +go get -tool github.com/99designs/gqlgen@latest if ERRORLEVEL 1 ( popd exit /b %ERRORLEVEL% ) -go run github.com/99designs/gqlgen generate +go tool gqlgen genreate if ERRORLEVEL 1 ( popd exit /b %ERRORLEVEL% diff --git a/go.mod b/go.mod index 1de50b6b..e4113739 100644 --- a/go.mod +++ b/go.mod @@ -62,6 +62,7 @@ require ( github.com/quic-go/quic-go v0.61.0 // indirect github.com/sosodev/duration v1.4.0 // indirect github.com/spiffe/go-spiffe/v2 v2.8.1 // indirect + github.com/urfave/cli/v3 v3.14.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect @@ -120,3 +121,5 @@ require ( golang.org/x/text v0.43.0 // indirect google.golang.org/protobuf v1.36.12 // indirect ) + +tool github.com/99designs/gqlgen diff --git a/go.sum b/go.sum index 9035f04d..4080edfc 100644 --- a/go.sum +++ b/go.sum @@ -211,6 +211,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= +github.com/urfave/cli/v3 v3.14.0 h1:a8414NQlHJs0c/iBsulKLzlES0n/lEAskbL2LKpU4/s= +github.com/urfave/cli/v3 v3.14.0/go.mod h1:vXn6HxPNccJSzQr2QvwVncOKrgYGIHU0HY5h8B2nQj4= github.com/vektah/gqlparser/v2 v2.5.64 h1:N32yM6hQ6Kd5RdjCCEJsUrbCebVoA9yLLMOIa88Mkk0= github.com/vektah/gqlparser/v2 v2.5.64/go.mod h1:nILRSUbsWDTuf8hSmAgFxuYh0SaMZdkvl6JSEbkJX8g= github.com/vikstrous/dataloadgen v0.0.10 h1:x07XAeEjIWXohvcjRvE72KY8pV5A3sTbKEFmxcj9RNM= From 0844687ea763d295404132c43a1f1595b7c16e7b Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Tue, 10 Nov 2026 23:53:48 -0600 Subject: [PATCH 57/73] Add generate command to Makefile --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index c791b865..84330ae9 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,11 @@ docs-rest: docs: docs-rest +generate: + cd graphql && go get -tool github.com/99designs/gqlgen@latest + cd graphql && go tool gqlgen generate + go mod tidy + build-rest: docs-rest go build -o $(REST_EXEC_NAME) ./rest From c8ffea0ad595a03485fe37467ac3e2f382e4c6ee Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Wed, 11 Nov 2026 01:25:15 -0600 Subject: [PATCH 58/73] Fix lint --- graphql/graph/comet_calendar.resolvers.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graphql/graph/comet_calendar.resolvers.go b/graphql/graph/comet_calendar.resolvers.go index 1340ae3c..739075ec 100644 --- a/graphql/graph/comet_calendar.resolvers.go +++ b/graphql/graph/comet_calendar.resolvers.go @@ -74,9 +74,8 @@ func (r *queryResolver) CometCalendar(ctx context.Context, id bson.ObjectID) (*m defer cancel() var calendar model.CometCalendar - var err error - err = r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": id}).Decode(&calendar) + err := r.CometCalendarCollection.FindOne(timeoutCtx, bson.M{"_id": id}).Decode(&calendar) if err != nil { if errors.Is(err, mongo.ErrNoDocuments) { return nil, fmt.Errorf("calendar not found: cannot find collection") From b72c07156ac827bef9b14a57c81a471d73d7239a Mon Sep 17 00:00:00 2001 From: Chris Torres Date: Thu, 12 Nov 2026 12:26:24 -0600 Subject: [PATCH 59/73] Remove old/obsolete CLUBS_DB_URI panic test --- rest/configs/env_test.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/rest/configs/env_test.go b/rest/configs/env_test.go index 4ad5cd22..1720ba42 100644 --- a/rest/configs/env_test.go +++ b/rest/configs/env_test.go @@ -166,19 +166,6 @@ func TestGetClubsDBUri(t *testing.T) { t.Errorf("expected %q, got %q", expected, uri) } }) - - /*t.Run("Unset panics", func(t *testing.T) { - - unsetEnv(t, "CLUBS_DB_URI") - - defer func() { - if recovered := recover(); recovered == nil { - t.Error("expected a panic when CLUBS_DB_URI is unset") - } - }() - - GetClubsDBUri() - })*/ } func TestGetEnvLogin(t *testing.T) { From eaf026301b60995dc6a44a4b08814d9745129b7d Mon Sep 17 00:00:00 2001 From: ThatRell Date: Sat, 14 Nov 2026 03:15:18 -0600 Subject: [PATCH 60/73] simplified and completed implementation --- .gitignore | 3 + rest/configs/setup.go | 76 ++++++++++++++++ rest/controllers/semesters.go | 164 ++-------------------------------- rest/server.go | 6 ++ 4 files changed, 90 insertions(+), 159 deletions(-) diff --git a/.gitignore b/.gitignore index ded428b1..d14385c6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,5 +33,8 @@ bin/ go.work go.work.sum +# semesters json +semesters.json + # API executables rest-api \ No newline at end of file diff --git a/rest/configs/setup.go b/rest/configs/setup.go index 400934a5..bc504c02 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -3,7 +3,11 @@ package configs import ( "context" "database/sql" + "encoding/json" + "os" + "sort" "strconv" + "strings" "sync" "time" @@ -137,3 +141,75 @@ func ConnectClubsDB() *sql.DB { return clubsDbInstance } + +// make sure this file is in gitignore if changed +const SemestersJSONFilename = "semesters.json" + +func CreateSemestersJSON() error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + terms, err := GetCollection("sections").Distinct(ctx, "academic_session.name", bson.D{}) + if err != nil { + return err + } + + type term struct { + name string + year int + season string + } + + var parsedTerms []term + seen := make(map[string]struct{}) + + for _, t := range terms { + str, ok := t.(string) + if !ok || len(str) < 3 { + continue + } + + str = strings.ToLower(strings.TrimSpace(str)) + + // Solution for possible duplicate value case (if database query returns '24F' and '24f') + if _, exists := seen[str]; exists { + continue + } + + year, err := strconv.Atoi(str[:2]) + if err != nil { + continue + } + parsedTerms = append(parsedTerms, term{ + name: str, + year: year, + season: str[2:], + }) + } + + // Sort terms by recency + sort.Slice(parsedTerms, func(i, j int) bool { + if parsedTerms[i].year != parsedTerms[j].year { + return parsedTerms[i].year > parsedTerms[j].year + } + // Sort by season (comparing ascii values) + return parsedTerms[i].season > parsedTerms[j].season + }) + + sortedTerms := make([]string, len(parsedTerms)) + for i, t := range parsedTerms { + sortedTerms[i] = t.name + } + + jsonData, err := json.Marshal(sortedTerms) + if err != nil { + return err + } + + err = os.WriteFile(SemestersJSONFilename, jsonData, 0644) + if err != nil { + return err + } + + return nil +} diff --git a/rest/controllers/semesters.go b/rest/controllers/semesters.go index aeb0d790..a6f5adaf 100644 --- a/rest/controllers/semesters.go +++ b/rest/controllers/semesters.go @@ -1,36 +1,13 @@ package controllers import ( - "context" "encoding/json" "net/http" "os" - "sort" - "strconv" - "strings" - "sync" - "time" + "github.com/UTDNebula/nebula-api/rest/configs" _ "github.com/UTDNebula/nebula-api/rest/schema" "github.com/gin-gonic/gin" - "go.mongodb.org/mongo-driver/bson" -) - -type cacheFile struct { - LastUpdated time.Time `json:"lastUpdated"` - Terms []string `json:"terms"` -} - -const ( - filename = "semesters.json" - fileTTL = 30 * 24 * time.Hour // 30 days -) - -var ( - semesters []string - lastUpdated time.Time - isLoaded bool - mutex sync.RWMutex ) // @Id semesters @@ -41,142 +18,11 @@ var ( // @Success 200 {object} schema.APIResponse[[]string] "A string list of all available terms, lowercased" // @Failure 500 {object} schema.APIResponse[string] "A string describing the error" func Semesters(c *gin.Context) { - ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second) - defer cancel() - - mutex.RLock() - needsRefresh := !isLoaded || cacheExpired(lastUpdated) - mutex.RUnlock() - - if needsRefresh { - err := loadOrRefresh(ctx) - if err != nil { - respondWithInternalError(c, err) - return - } - } - - mutex.RLock() - data := semesters - mutex.RUnlock() - - respond(c, http.StatusOK, "success", data) -} - -func loadOrRefresh(ctx context.Context) error { - // Prevent other calls from r/w json file - mutex.Lock() - defer mutex.Unlock() - - if isLoaded && !cacheExpired(lastUpdated) { - return nil - } - - if !isLoaded { - // Check if json file exists - fileBytes, err := os.ReadFile(filename) - if err == nil { - var fileData cacheFile - if err := json.Unmarshal(fileBytes, &fileData); err == nil { - // Check if file data is outdated, load and return if not - if time.Since(fileData.LastUpdated) <= fileTTL { - semesters = fileData.Terms - lastUpdated = fileData.LastUpdated - isLoaded = true - return nil - } - } - } - } - - sortedTerms, err := getSortedTerms(ctx) + fileBytes, err := os.ReadFile(configs.SemestersJSONFilename) if err != nil { - return err + respondWithInternalError(c, err) + return } - currTime := time.Now() - - newData := cacheFile{ - LastUpdated: currTime, - Terms: sortedTerms, - } - - fileBytes, err := json.Marshal(newData) - if err != nil { - return err - } - - // Create new json file with updated data - err = os.WriteFile(filename, fileBytes, 0644) - if err != nil { - return err - } - - // Update global variables - semesters = sortedTerms - lastUpdated = currTime - isLoaded = true - - return nil -} - -func getSortedTerms(ctx context.Context) ([]string, error) { - - type term struct { - name string - year int - season string - } - - terms, err := sectionCollection.Distinct(ctx, "academic_session.name", bson.D{}) - if err != nil { - return nil, err - } - - var parsedTerms []term - seen := make(map[string]struct{}) - - for _, t := range terms { - str, ok := t.(string) - if !ok || len(str) < 3 { - continue - } - - str = strings.ToLower(strings.TrimSpace(str)) - - // Solution to possible duplicate value case (if database query returns '24F' and '24f') - if _, exists := seen[str]; exists { - continue - } - - year, err := strconv.Atoi(str[:2]) - if err != nil { - continue - } - parsedTerms = append(parsedTerms, term{ - name: str, - year: year, - season: str[2:], - }) - } - - // Sort terms by recency - sort.Slice(parsedTerms, func(i, j int) bool { - if parsedTerms[i].year != parsedTerms[j].year { - return parsedTerms[i].year > parsedTerms[j].year - } - - // Sort by season (comparing ascii values) - return parsedTerms[i].season > parsedTerms[j].season - }) - - sortedTerms := make([]string, len(parsedTerms)) - for i, t := range parsedTerms { - sortedTerms[i] = t.name - } - - return sortedTerms, nil -} -func cacheExpired(updatedAt time.Time) bool { - return updatedAt.IsZero() || time.Since(updatedAt) > fileTTL + respond(c, http.StatusOK, "success", json.RawMessage(fileBytes)) } diff --git a/rest/server.go b/rest/server.go index 439c7077..4d536975 100644 --- a/rest/server.go +++ b/rest/server.go @@ -48,6 +48,12 @@ func main() { configs.ConnectDB() configs.ConnectClubsDB() + // Create JSON file for /semesters endpoint + err := configs.CreateSemestersJSON() + if err != nil { + log.Fatalf("Unable to create Semesters JSON") + } + // Set up Sentry if err := sentry.Init(sentry.ClientOptions{ Dsn: configs.GetEnvSentryDSN(), From 2f426ea800952303bcc96959cc3ee371741ea70c Mon Sep 17 00:00:00 2001 From: ThatRell Date: Sat, 14 Nov 2026 04:06:39 -0600 Subject: [PATCH 61/73] basic logging on setup.go --- rest/configs/setup.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest/configs/setup.go b/rest/configs/setup.go index bc504c02..24be22ce 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -153,6 +153,7 @@ func CreateSemestersJSON() error { if err != nil { return err } + log.Printf("Aggregated semesters from MongoDB") type term struct { name string @@ -211,5 +212,6 @@ func CreateSemestersJSON() error { return err } + log.Printf("Created semesters JSON file") return nil } From 1c6b6cac8d2b36685ddaff4f0b569fcd28b04d24 Mon Sep 17 00:00:00 2001 From: ThatRell Date: Sat, 14 Nov 2026 05:30:55 -0600 Subject: [PATCH 62/73] fixed v2 migration bugs, fixed sorting issues --- go.mod | 7 +++---- go.sum | 14 ++++++-------- rest/configs/setup.go | 20 +++++++++++++------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 3c190f5b..1bfd93ea 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/swag v1.16.6 - go.mongodb.org/mongo-driver/v2 v2.9.1 + go.mongodb.org/mongo-driver/v2 v2.10.0 google.golang.org/api v0.293.0 ) @@ -90,7 +90,7 @@ require ( github.com/goccy/go-json v0.10.6 // indirect github.com/jackc/pgx/v5 v5.10.0 github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.19.2 // indirect + github.com/klauspost/compress v1.20.3 // indirect github.com/klauspost/cpuid/v2 v2.4.0 // indirect github.com/leodido/go-urn v1.5.0 // indirect github.com/mattn/go-isatty v0.0.24 // indirect @@ -99,8 +99,7 @@ require ( github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.3.2 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.2.0 // indirect + github.com/xdg-go/scram v1.4.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect golang.org/x/arch v0.30.0 // indirect diff --git a/go.sum b/go.sum index 8115b5eb..099450f1 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,8 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8= -github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= +github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw= github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU= github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0= @@ -197,17 +197,15 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.2.0 h1:bYKF2AEwG5rqd1BumT4gAnvwU/M9nBp2pTSxeZw7Wvs= -github.com/xdg-go/scram v1.2.0/go.mod h1:3dlrS0iBaWKYVt2ZfA4cj48umJZ+cAEbR6/SjLA88I8= +github.com/xdg-go/scram v1.4.0 h1:3/wY9vMc786lAsuowR1CGxl0oVQDUWnCliDnWKhiZJs= +github.com/xdg-go/scram v1.4.0/go.mod h1:rWC+ac5XyfRhG8rI7Css3P9K+/sjzldRjM9PI7VPlNM= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver/v2 v2.9.1 h1:jewiFs2m1/VOQp8qhFshX6hWZ+EAXDhZHXExAUMcOgQ= -go.mongodb.org/mongo-driver/v2 v2.9.1/go.mod h1:SHKN0IWkKmEVGHLjXnni6s4wPKX4v86FTgOeJJFuXcA= +go.mongodb.org/mongo-driver/v2 v2.10.0 h1:BYJLuVSu3/xDvToG+VQyoTPS+jxq9tuQDf+1nAlFKSE= +go.mongodb.org/mongo-driver/v2 v2.10.0/go.mod h1:PxPyIAlsI1jkYZvUNfTr++ggyBP+RSaxHYctt6TcZc4= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/detectors/gcp v1.45.0 h1:9jR0ZPRok9ryaOQ2Wx8rg5F7Aon59mxrqbVI60/vlBk= diff --git a/rest/configs/setup.go b/rest/configs/setup.go index e6e61cb2..4fd76862 100644 --- a/rest/configs/setup.go +++ b/rest/configs/setup.go @@ -149,8 +149,13 @@ func CreateSemestersJSON() error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - terms, err := GetCollection("sections").Distinct(ctx, "academic_session.name", bson.D{}) - if err != nil { + res := GetCollection("sections").Distinct(ctx, "academic_session.name", bson.D{}) + if err := res.Err(); err != nil { + return err + } + + var terms []string + if err := res.Decode(&terms); err != nil { return err } log.Printf("Aggregated semesters from MongoDB") @@ -164,9 +169,8 @@ func CreateSemestersJSON() error { var parsedTerms []term seen := make(map[string]struct{}) - for _, t := range terms { - str, ok := t.(string) - if !ok || len(str) < 3 { + for _, str := range terms { + if len(str) < 3 { continue } @@ -188,13 +192,15 @@ func CreateSemestersJSON() error { }) } + seasonOrder := map[string]int{"f": 3, "u": 2, "s": 1} + // Sort terms by recency sort.Slice(parsedTerms, func(i, j int) bool { if parsedTerms[i].year != parsedTerms[j].year { return parsedTerms[i].year > parsedTerms[j].year } - // Sort by season (comparing ascii values) - return parsedTerms[i].season > parsedTerms[j].season + // Sort by season + return seasonOrder[parsedTerms[i].season] > seasonOrder[parsedTerms[j].season] }) sortedTerms := make([]string, len(parsedTerms)) From 2bb32b7f618cca35022fb3cafc1587993fc560fd Mon Sep 17 00:00:00 2001 From: Ashwin Avadhanula Date: Mon, 16 Nov 2026 10:19:56 -0600 Subject: [PATCH 63/73] Update storage_test.go --- rest/controllers/storage_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/controllers/storage_test.go b/rest/controllers/storage_test.go index 29707994..e3ef10d0 100644 --- a/rest/controllers/storage_test.go +++ b/rest/controllers/storage_test.go @@ -43,7 +43,7 @@ func TestMaxUploadSize(t *testing.T) { defer func() { if r := recover(); r != nil { - t.Fatalf("Recover panicked unexpectedly") + t.Fatalf("Recover panicked unexpectedly: %v", r) } }() From 650e0815c2a39a4d0da1b6bee19e742782895e67 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Mon, 16 Nov 2026 22:20:05 -0600 Subject: [PATCH 64/73] fix(api): add id to academic programs --- rest/schema/objects.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rest/schema/objects.go b/rest/schema/objects.go index 18026baa..57660daf 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -350,10 +350,11 @@ type AcademicCalendarDropDeadlines struct { } type AcademicProgram struct { - Title string `bson:"name" json:"name" queryable:""` - School string `bson:"school" json:"school" queryable:""` - DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` - AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` + Id primitive.ObjectID `bson:"_id" json:"_id"` + Title string `bson:"name" json:"name" queryable:""` + School string `bson:"school" json:"school" queryable:""` + DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` + AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` } type Degree struct { From 88565a14ab73406bd030f6323111ca1ac7a12acd Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Mon, 16 Nov 2026 22:25:19 -0600 Subject: [PATCH 65/73] fix(api): use current MongoDB ID type --- rest/schema/objects.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/schema/objects.go b/rest/schema/objects.go index 57660daf..b0ec8dfa 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -350,7 +350,7 @@ type AcademicCalendarDropDeadlines struct { } type AcademicProgram struct { - Id primitive.ObjectID `bson:"_id" json:"_id"` + Id bson.ObjectID `bson:"_id" json:"_id"` Title string `bson:"name" json:"name" queryable:""` School string `bson:"school" json:"school" queryable:""` DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` From 3bc4d448f9a3de217612f656156fbc001f63cb58 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Mon, 16 Nov 2026 22:29:58 -0600 Subject: [PATCH 66/73] ci: rerun pull request checks From 0d8bcefb8c441d0d2f58fa3c5b47bde83bbd2da4 Mon Sep 17 00:00:00 2001 From: Samartha Bapat Date: Mon, 16 Nov 2026 22:40:32 -0600 Subject: [PATCH 67/73] ci: rerun checks From e51bb53aa640bc6ce76860e9ced94de24e712a0d Mon Sep 17 00:00:00 2001 From: LazyFork Date: Tue, 17 Nov 2026 18:32:23 -0600 Subject: [PATCH 68/73] replace mock ids with valid ids in tests --- rest/controllers/course_test.go | 2 +- rest/controllers/section_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rest/controllers/course_test.go b/rest/controllers/course_test.go index b6adff09..a55aae42 100644 --- a/rest/controllers/course_test.go +++ b/rest/controllers/course_test.go @@ -23,7 +23,7 @@ func TestCourseById(t *testing.T) { }{ { name: "ReturnCourseSuccessfully", - id: "6a8f623120b48b6efe790172", + id: "6afa8ba7c82a15eca4f610bb", expectedStatus: http.StatusOK, expectedResponseMessage: "success", }, diff --git a/rest/controllers/section_test.go b/rest/controllers/section_test.go index b921a8da..a7d1118e 100644 --- a/rest/controllers/section_test.go +++ b/rest/controllers/section_test.go @@ -23,7 +23,7 @@ func TestSectionCourseById(t *testing.T) { }{ { name: "ReturnCourseSuccessfully", - id: "6a8f623120b48b6efe790176", + id: "6afa8ba8c82a15eca4f623f4", expectedStatus: http.StatusOK, expectedResponseMessage: "success", }, From d24209f254521d4fe6fac5a88c8d8e536d989797 Mon Sep 17 00:00:00 2001 From: mikehquan19 Date: Wed, 25 Nov 2026 23:30:58 -0600 Subject: [PATCH 69/73] fix: fix the ci-lint for newly created degrees endpoint --- rest/controllers/degrees.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/controllers/degrees.go b/rest/controllers/degrees.go index 15d74415..ff609241 100644 --- a/rest/controllers/degrees.go +++ b/rest/controllers/degrees.go @@ -48,7 +48,7 @@ func Degrees(c *gin.Context) { respondWithInternalError(c, err) return } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() degrees := make([]schema.AcademicProgram, 0) if err = cursor.All(ctx, °rees); err != nil { From 9ddd585e02e5d952d92cac824f67dd7cc76e9db0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 05:39:54 +0000 Subject: [PATCH 70/73] build(deps): bump go.opentelemetry.io/otel/sdk from 1.45.0 to 1.47.0 Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.45.0 to 1.47.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.45.0...v1.47.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/sdk dependency-version: 1.47.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 15 ++++++++------- go.sum | 58 +++++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 025e7085..717da31d 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.26.0 require ( cloud.google.com/go/storage v1.65.0 + github.com/fsouza/fake-gcs-server v1.56.1 github.com/getsentry/sentry-go v0.48.0 github.com/getsentry/sentry-go/gin v0.48.0 github.com/gin-gonic/gin v1.12.0 @@ -36,7 +37,6 @@ require ( github.com/envoyproxy/go-control-plane/envoy v1.39.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.3.3 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect - github.com/fsouza/fake-gcs-server v1.56.1 // indirect github.com/go-jose/go-jose/v4 v4.1.6 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -65,11 +65,12 @@ require ( go.opentelemetry.io/contrib/detectors/gcp v1.45.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect - go.opentelemetry.io/otel v1.45.0 // indirect - go.opentelemetry.io/otel/metric v1.45.0 // indirect - go.opentelemetry.io/otel/sdk v1.45.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect - go.opentelemetry.io/otel/trace v1.45.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/sdk v1.47.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/oauth2 v0.36.0 // indirect golang.org/x/time v0.15.0 // indirect @@ -114,7 +115,7 @@ require ( golang.org/x/mod v0.40.0 // indirect golang.org/x/net v0.58.0 // indirect golang.org/x/sync v0.22.0 // indirect - golang.org/x/sys v0.47.0 // indirect + golang.org/x/sys v0.48.0 // indirect golang.org/x/text v0.41.0 // indirect google.golang.org/protobuf v1.36.12 // indirect ) diff --git a/go.sum b/go.sum index b97dd4aa..b1c6709f 100644 --- a/go.sum +++ b/go.sum @@ -53,6 +53,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -131,6 +133,8 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -185,10 +189,18 @@ github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTf github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw= github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU= +github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM= +github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw= github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0= github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE= github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI= github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= +github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI= +github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= +github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= +github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= +github.com/minio/minio-go/v7 v7.3.0 h1:HM4pFCSQq/TK+j0/zmorSh5ddh81iDgRgU0BG0Vz/YU= +github.com/minio/minio-go/v7 v7.3.0/go.mod h1:KUPWdecEO1LWyUz+sTGXAuf2jZHrPh5fCsRH86QbPfk= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -196,6 +208,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -205,8 +219,6 @@ github.com/pkg/xattr v0.4.12/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6k github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0= github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk= @@ -214,6 +226,8 @@ github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII= github.com/quic-go/quic-go v0.61.0 h1:ui88A53s8MSVYLC56en0KQ17HARk+9986Dn0SBfKNvA= github.com/quic-go/quic-go v0.61.0/go.mod h1:9So2anK4Tp22URSQq00k+Vo2PNkle96ycDPDHL4s9vs= +github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/spiffe/go-spiffe/v2 v2.8.1 h1:eXZMLsu+3MLEPJyGJkolqtVrteZfQdUpOWj6LTiDl/E= github.com/spiffe/go-spiffe/v2 v2.8.1/go.mod h1:47Q0Q9/AqGha8QLHp+kxpH4Wca7X7EnOtlIJy3mxZ3U= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -227,15 +241,16 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY= github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw= github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI= github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg= +github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ= +github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc= @@ -247,6 +262,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs= +github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s= go.mongodb.org/mongo-driver/v2 v2.10.0 h1:BYJLuVSu3/xDvToG+VQyoTPS+jxq9tuQDf+1nAlFKSE= go.mongodb.org/mongo-driver/v2 v2.10.0/go.mod h1:PxPyIAlsI1jkYZvUNfTr++ggyBP+RSaxHYctt6TcZc4= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= @@ -259,20 +276,22 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.7 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0/go.mod h1:DqEFwLumhzMBDQv9PcWbyoDxHI/4lAk6CM4nJBH39sc= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 h1:LMuyCAyfalSjDyjdC65nK6N0zoTT63+E/u95X0JovZI= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0/go.mod h1:085m8qbm4hgc8rZWGDEa4vmyyo2c3nPxUslYUKUIU04= -go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU= -go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 h1:hqxVTu/GtBF+vJ8d1fzW7fRxZFvgoDjWcxwwCaFDYpU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0/go.mod h1:z5fVEF4X5v0ESvlJqBrrFlBVoj5EQuefZpzsu7R+x5Q= -go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M= -go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s= -go.opentelemetry.io/otel/metric/x v0.67.0 h1:PcicCNZFkZ4bXfSooXdo3WN7RBOVOtjVdo1wD358Uns= -go.opentelemetry.io/otel/metric/x v0.67.0/go.mod h1:FBjCWZe6wgcqxcMtjdGiClDKXb2YxxXii0CXftE4QtI= -go.opentelemetry.io/otel/sdk v1.45.0 h1:4VVSMgQ83dUgW2aoX5f6JgLvHwIvzcuLnF9lUdCSpCw= -go.opentelemetry.io/otel/sdk v1.45.0/go.mod h1:Sr40LgXV7DsKMMJMKOhUWOgMWTfAaqvm2kF0g7ilwuA= -go.opentelemetry.io/otel/sdk/metric v1.45.0 h1:oVFszMfyj1Am6s24Vtc7wBb8BKLcwepJjNEYILuiE3o= -go.opentelemetry.io/otel/sdk/metric v1.45.0/go.mod h1:vUWUxDZvu1WVRj8JA8S0AdhsPrZoDpA2DdZauIh4mDA= -go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag= -go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= +go.opentelemetry.io/otel/metric/x v0.69.0 h1:DjRLr15H83v+hCW7JA9NoJvOkYTtmq5YoDRbe9deYpM= +go.opentelemetry.io/otel/metric/x v0.69.0/go.mod h1:uVvsMPMFFyj/HUQfrUnH3JjnOQ1dwFDorgFLRBasM0k= +go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I= +go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0= +go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw= +go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= @@ -324,8 +343,8 @@ golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= -golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo= +golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -383,8 +402,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.67.3 h1:iM9Lhz5MRSGhHVGGwCuzG9KO8PoirCXj/m/qTmOJJQw= +gopkg.in/ini.v1 v1.67.3/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 4aabfe90be9af2edeaaa3482a5cb4b10b4c5ea14 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Sun, 29 Nov 2026 21:58:57 -0600 Subject: [PATCH 71/73] Format code --- rest/controllers/degrees.go | 2 +- rest/controllers/semesters.go | 2 +- rest/routes/club.go | 2 +- rest/schema/objects.go | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rest/controllers/degrees.go b/rest/controllers/degrees.go index 9269ede6..f4d057d0 100644 --- a/rest/controllers/degrees.go +++ b/rest/controllers/degrees.go @@ -5,8 +5,8 @@ import ( "net/http" "time" - "github.com/UTDNebula/nebula-api/shared/configs" "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/UTDNebula/nebula-api/shared/configs" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/v2/mongo" ) diff --git a/rest/controllers/semesters.go b/rest/controllers/semesters.go index 8e9e046f..30bb9a60 100644 --- a/rest/controllers/semesters.go +++ b/rest/controllers/semesters.go @@ -5,8 +5,8 @@ import ( "net/http" "os" - "github.com/UTDNebula/nebula-api/shared/configs" _ "github.com/UTDNebula/nebula-api/rest/schema" + "github.com/UTDNebula/nebula-api/shared/configs" "github.com/gin-gonic/gin" ) diff --git a/rest/routes/club.go b/rest/routes/club.go index 32cbb208..f8c4fb5a 100644 --- a/rest/routes/club.go +++ b/rest/routes/club.go @@ -3,8 +3,8 @@ package routes import ( "log" - "github.com/UTDNebula/nebula-api/shared/configs" "github.com/UTDNebula/nebula-api/rest/controllers" + "github.com/UTDNebula/nebula-api/shared/configs" "github.com/gin-gonic/gin" ) diff --git a/rest/schema/objects.go b/rest/schema/objects.go index b0ec8dfa..b59c56d0 100644 --- a/rest/schema/objects.go +++ b/rest/schema/objects.go @@ -350,11 +350,11 @@ type AcademicCalendarDropDeadlines struct { } type AcademicProgram struct { - Id bson.ObjectID `bson:"_id" json:"_id"` - Title string `bson:"name" json:"name" queryable:""` - School string `bson:"school" json:"school" queryable:""` - DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` - AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` + Id bson.ObjectID `bson:"_id" json:"_id"` + Title string `bson:"name" json:"name" queryable:""` + School string `bson:"school" json:"school" queryable:""` + DegreeOptions []Degree `bson:"degree_options" json:"degree_options" queryable:""` + AreasOfInterest []string `bson:"areas_of_interest" json:"areas_of_interest" queryable:""` } type Degree struct { From 0ca82d8a89dd9cb67e24f761b8f8959a34754b86 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Mon, 30 Nov 2026 00:14:00 -0600 Subject: [PATCH 72/73] Fix errcheck lint issues for graphql --- graphql/graph/comet_calendar.resolvers.go | 2 +- graphql/graph/course.resolvers.go | 2 +- graphql/graph/model/scalars.go | 2 +- graphql/graph/professor.resolvers.go | 2 +- graphql/graph/room.resolvers.go | 2 +- graphql/graph/section.resolvers.go | 2 +- graphql/loaders/professor.go | 2 +- graphql/loaders/section.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/graphql/graph/comet_calendar.resolvers.go b/graphql/graph/comet_calendar.resolvers.go index 739075ec..dbb73af4 100644 --- a/graphql/graph/comet_calendar.resolvers.go +++ b/graphql/graph/comet_calendar.resolvers.go @@ -35,7 +35,7 @@ func (r *queryResolver) CometCalendars(ctx context.Context, filter *model.CometC if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() var calendars []*model.CometCalendar if err = cursor.All(timeoutCtx, &calendars); err != nil { diff --git a/graphql/graph/course.resolvers.go b/graphql/graph/course.resolvers.go index 7684ec4a..76f908c8 100644 --- a/graphql/graph/course.resolvers.go +++ b/graphql/graph/course.resolvers.go @@ -38,7 +38,7 @@ func (r *queryResolver) Courses(ctx context.Context, filter *model.CourseFilter, if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() // Unmarshal into courses if err = cursor.All(timeoutCtx, &courses); err != nil { diff --git a/graphql/graph/model/scalars.go b/graphql/graph/model/scalars.go index d7e53528..794d5d3f 100644 --- a/graphql/graph/model/scalars.go +++ b/graphql/graph/model/scalars.go @@ -13,7 +13,7 @@ import ( // Marshaller for ObjectID scalar type func MarshalObjectID(id bson.ObjectID) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { - io.WriteString(w, fmt.Sprintf("%q", id.Hex())) + _, _ = io.WriteString(w, fmt.Sprintf("%q", id.Hex())) }) } diff --git a/graphql/graph/professor.resolvers.go b/graphql/graph/professor.resolvers.go index b5e63969..ea795d50 100644 --- a/graphql/graph/professor.resolvers.go +++ b/graphql/graph/professor.resolvers.go @@ -35,7 +35,7 @@ func (r *queryResolver) Professors(ctx context.Context, filter *model.ProfessorF if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() if err = cursor.All(timeoutCtx, &professors); err != nil { return nil, err diff --git a/graphql/graph/room.resolvers.go b/graphql/graph/room.resolvers.go index b43f688e..a56493c5 100644 --- a/graphql/graph/room.resolvers.go +++ b/graphql/graph/room.resolvers.go @@ -21,7 +21,7 @@ func (r *queryResolver) Rooms(ctx context.Context) ([]*model.BuildingRooms, erro if err != nil { return buildingRooms, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() if err = cursor.All(ctx, &buildingRooms); err != nil { return buildingRooms, err diff --git a/graphql/graph/section.resolvers.go b/graphql/graph/section.resolvers.go index 2f1ffa99..4fd2642e 100644 --- a/graphql/graph/section.resolvers.go +++ b/graphql/graph/section.resolvers.go @@ -39,7 +39,7 @@ func (r *queryResolver) Sections(ctx context.Context, filter *model.SectionFilte if err != nil { return nil, err } - defer cursor.Close(timeoutCtx) + defer func() { _ = cursor.Close(timeoutCtx) }() // Decode if err := cursor.All(timeoutCtx, §ions); err != nil { diff --git a/graphql/loaders/professor.go b/graphql/loaders/professor.go index c9b6e816..0f00df59 100644 --- a/graphql/loaders/professor.go +++ b/graphql/loaders/professor.go @@ -19,7 +19,7 @@ func (p *professorReader) getProfessors(ctx context.Context, professorIDs []bson if err != nil { return nil, []error{err} } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() var professors []*model.Professor if err := cursor.All(ctx, &professors); err != nil { diff --git a/graphql/loaders/section.go b/graphql/loaders/section.go index 0d806079..cbecc34c 100644 --- a/graphql/loaders/section.go +++ b/graphql/loaders/section.go @@ -20,7 +20,7 @@ func (s *sectionReader) getSections(ctx context.Context, sectionIDs []bson.Objec if err != nil { return nil, []error{err} } - defer cursor.Close(ctx) + defer func() { _ = cursor.Close(ctx) }() // Decode var sections []*model.Section From 0176d55f77d2466dde53f317cbd68f4ff45e6b74 Mon Sep 17 00:00:00 2001 From: Kim Bui Date: Mon, 30 Nov 2026 00:23:46 -0600 Subject: [PATCH 73/73] Remove default limit on lint issues golangci-lint defaults to 3 issues max so if there's more than 3 issues, you'd have to run the lint command multiple times --- Makefile | 2 +- build.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9a642876..45081edd 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ format: go mod tidy gofmt -w . goimports -w . - golangci-lint run ./... + golangci-lint run ./... --max-issues-per-linter 0 --max-same-issues 0 check: go mod tidy diff --git a/build.bat b/build.bat index aac2bed3..a4a3007c 100644 --- a/build.bat +++ b/build.bat @@ -91,7 +91,7 @@ gofmt -w . if ERRORLEVEL 1 exit /b %ERRORLEVEL% goimports -w . if ERRORLEVEL 1 exit /b %ERRORLEVEL% -golangci-lint run ./... +golangci-lint run ./... --max-issues-per-linter 0 --max-same-issues 0 if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo Checks done! echo.