Conversation
124fd51 to
8f5cd1f
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements full CRUD support for the Routes resource in the FastAPI backend and refactors Agencies to follow the same service-layer pattern, plus some minor import/formatting cleanups across the repo.
Changes:
- Implemented Routes CRUD endpoints and added a
route_servicebusiness-logic layer. - Refactored Agencies endpoints to use a new
agency_servicebusiness-logic layer with consistent error handling and empty-update validation. - Performed minor import ordering/formatting adjustments in backend modules and migrations.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/app/page.tsx | Removes an extraneous blank line in the home page layout. |
| backend/setup.py | Reorders setuptools imports. |
| backend/server.py | Adds a blank line between stdlib and third-party imports. |
| backend/migrations/versions/2adf14c14d9c_initial.py | Reorders imports in migration. |
| backend/migrations/versions/20260215_hafb_tables.py | Reorders imports in migration. |
| backend/migrations/versions/20260215_complete_schema_redesign.py | Reorders imports in migration. |
| backend/migrations/env.py | Adjusts import ordering for settings/models registration. |
| backend/app/services/routes.py | New: service layer implementing list/get/create/update/delete for routes incl. datetime normalization. |
| backend/app/services/agencies.py | New: service layer implementing CRUD operations for agencies incl. empty-update validation and IntegrityError handling. |
| backend/app/services/init.py | New: service package exports (agency_service, route_service). |
| backend/app/models/base.py | Import formatting changes only. |
| backend/app/models/init.py | Import formatting changes only. |
| backend/app/main.py | Import ordering cleanup. |
| backend/app/database.py | Import formatting cleanup. |
| backend/app/config.py | Import ordering cleanup. |
| backend/app/api/routes.py | Implements full CRUD endpoints for routes, delegating to route_service. |
| backend/app/api/agencies.py | Refactors endpoints to delegate to agency_service and adds consistent error handling / 204 response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8f5cd1f to
365fb80
Compare
| detail=str(e), | ||
| ) from e | ||
|
|
||
| return Response(status_code=status.HTTP_204_NO_CONTENT) |
There was a problem hiding this comment.
possibly redundant since FastAPI automatically sends 204 from the decorator
| """ | ||
|
|
||
| from fastapi import APIRouter, Response, status | ||
| from fastapi import APIRouter, Depends, HTTPException, Response, status |
There was a problem hiding this comment.
also means Response can be removed from imports
| async def list_routes(db: AsyncSession) -> list[Route]: | ||
| """List all routes ordered by date.""" | ||
| result = await db.execute(select(Route).order_by(Route.date)) | ||
| return list(result.scalars().all()) |
There was a problem hiding this comment.
| return list(result.scalars().all()) | |
| return result.scalars().all() |
result.scalars().all() already returns a list, so wrapping it in list may be redundant
| await db.commit() | ||
| except IntegrityError as e: | ||
| await db.rollback() | ||
| logger.exception("IntegrityError creating route: %s", e.orig) |
| @@ -4,39 +4,39 @@ | |||
| Use this module as the reference pattern for other resources. | |||
There was a problem hiding this comment.
i think your agencies refactoring work might've been included in this PR! if that's what happened, i'd recommend reverting this file and deleting /services/agencies.py so this PR is only concerned with the routes CRUD
| Business logic layer; API routes depend on services, not the reverse. | ||
| """ | ||
|
|
||
| from . import agencies as agency_service |
There was a problem hiding this comment.
| from . import agencies as agency_service |
There was a problem hiding this comment.
once you decouple the agencies changes from the routes changes
| from . import donors as donor_service | ||
| from . import clients as clients_service | ||
|
|
||
| __all__ = ["agency_service", "route_service"] |
There was a problem hiding this comment.
| __all__ = ["agency_service", "route_service"] | |
| __all__ = ["route_service"] |
There was a problem hiding this comment.
once you decouple the agencies changes from the routes changes
| from sqlalchemy.exc import IntegrityError | ||
| from sqlalchemy.ext.asyncio import AsyncSession | ||
|
|
||
| logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
let's move this after the imports currently below it
Jira ticket link
Jira ticket
Implementation description
Steps to test
What should reviewers focus on?
Checklist
Format for branch, commit, and PR title: docs/GIT.md.