Skip to content

Conversation

@dmakarau
Copy link
Owner

API for categories: saving and deleting

@dmakarau dmakarau requested a review from Copilot October 10, 2025 14:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements comprehensive category management API functionality with endpoints for creating, fetching, and deleting categories. The implementation includes proper color code validation and normalization, comprehensive error handling, and user isolation.

Key changes:

  • Added category fetching and deletion endpoints with user isolation
  • Implemented color code normalization to ensure consistent # prefix formatting
  • Enhanced validation to accept both RRGGBB and #RRGGBB color code formats

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Sources/GrowBitAppServer/Controllers/HabitsController.swift Added getAllCategoriesForUser and deleteCategory endpoints with color normalization
Sources/GrowBitAppServer/Models/Category.swift Fixed validation error message typo and updated color pattern regex
Sources/GrowBitAppServer/Extensions/CategoryResponseDTO+Extensions.swift Corrected filename in header comment
Tests/GrowBitAppServerTests/GrowBitAppServerSavingCategoryTests.swift Enhanced test with color normalization validation and better invalid color test
Tests/GrowBitAppServerTests/GrowBitAppServerFetchingCategoriesTests.swift Added comprehensive test suite for category fetching functionality
Tests/GrowBitAppServerTests/GrowBitAppServerDeleteCategoryTests.swift Added comprehensive test suite for category deletion functionality
Tests/GrowBitAppServerTests/GrowBitAppServerLoginTests.swift Removed unused import
README.md Updated documentation to reflect implemented category CRUD operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dmakarau dmakarau requested a review from Copilot October 10, 2025 15:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

guard let userId = req.parameters.get("userId", as: UUID.self),
let categoryId = req.parameters.get("categoryId", as: UUID.self)
else {
throw Abort(.badRequest, reason: "Missing or invalid userId parameter") // HTTP 400
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The error message mentions only 'userId parameter' but the function validates both userId and categoryId parameters. Consider updating to 'Missing or invalid userId or categoryId parameter' for clarity.

Suggested change
throw Abort(.badRequest, reason: "Missing or invalid userId parameter") // HTTP 400
throw Abort(.badRequest, reason: "Missing or invalid userId or categoryId parameter") // HTTP 400

Copilot uses AI. Check for mistakes.
@dmakarau dmakarau merged commit 4a60313 into main Oct 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants