mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 08:21:15 +00:00
[AZ-284] Autodev baseline + testability refactor
Phase A baseline outputs from /autodev (Steps 1-5): - Problem & solution docs (_docs/00_problem, _docs/01_solution) - Codebase documentation (_docs/02_document) incl. architecture, module-layout, glossary, system-flows, baseline compliance scan - Test specs (blackbox, performance, resilience, security, resource, traceability matrix) - Test task decomposition (_docs/02_tasks/todo): AZ-285..AZ-290 - Testability refactor (_docs/04_refactoring/01-testability-refactoring): - TC-01 Move DownloadedTileInfoV2 + new ExistingTileInfo to Common.DTO - TC-02 Replace dead ISatelliteDownloader API with real signatures - TC-03 GoogleMapsDownloaderV2 implements ISatelliteDownloader - TC-04 TileService depends on ISatelliteDownloader (mockable) - TC-05 DI + endpoints use ISatelliteDownloader - Test runner scripts (scripts/run-tests.sh, run-performance-tests.sh) - Autodev state pointer (_docs/_autodev_state.md) Prepares the codebase for AZ-285..AZ-290 unit/integration test work. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# Module: DataAccess/Repositories/RouteRepository
|
||||
|
||||
## Purpose
|
||||
Dapper-based repository for the `routes`, `route_points`, and `route_regions` tables. Handles route persistence, point storage, and route-region linking (including geofence metadata).
|
||||
|
||||
## Public Interface
|
||||
|
||||
### IRouteRepository (interface)
|
||||
- `GetByIdAsync(Guid id) → Task<RouteEntity?>`
|
||||
- `GetRoutePointsAsync(Guid routeId) → Task<IEnumerable<RoutePointEntity>>`: ordered by `sequence_number`
|
||||
- `InsertRouteAsync(RouteEntity route) → Task<Guid>`
|
||||
- `InsertRoutePointsAsync(IEnumerable<RoutePointEntity> points) → Task`: bulk insert
|
||||
- `UpdateRouteAsync(RouteEntity route) → Task<int>`
|
||||
- `DeleteRouteAsync(Guid id) → Task<int>`
|
||||
- `LinkRouteToRegionAsync(Guid routeId, Guid regionId, bool isGeofence, int? geofencePolygonIndex) → Task`: inserts into `route_regions` with `ON CONFLICT DO NOTHING`
|
||||
- `GetRegionIdsByRouteAsync(Guid routeId) → Task<IEnumerable<Guid>>`: non-geofence region IDs
|
||||
- `GetGeofenceRegionIdsByRouteAsync(Guid routeId) → Task<IEnumerable<Guid>>`: geofence-only region IDs
|
||||
- `GetGeofenceRegionsByPolygonAsync(Guid routeId) → Task<Dictionary<int, List<Guid>>>`: groups geofence regions by polygon index
|
||||
- `GetRoutesWithPendingMapsAsync() → Task<IEnumerable<RouteEntity>>`: routes where `request_maps = true AND maps_ready = false`
|
||||
|
||||
### RouteRepository (implementation)
|
||||
Same connection-per-call pattern. `InsertRoutePointsAsync` uses Dapper's bulk execute to insert all points in a single round-trip.
|
||||
|
||||
## Internal Logic
|
||||
- `LinkRouteToRegionAsync` uses `ON CONFLICT DO NOTHING` to handle duplicate links gracefully
|
||||
- `GetGeofenceRegionsByPolygonAsync` groups results into a dictionary keyed by `geofence_polygon_index`
|
||||
- `GetRoutesWithPendingMapsAsync` drives the `RouteProcessingService` polling loop
|
||||
|
||||
## Dependencies
|
||||
- NuGet: `Dapper`, `Npgsql`
|
||||
- `SatelliteProvider.DataAccess.Models.RouteEntity`, `RoutePointEntity`
|
||||
- `Microsoft.Extensions.Logging`
|
||||
|
||||
## Consumers
|
||||
- `RouteService` — insert route, points, link regions
|
||||
- `RouteProcessingService` — read route state, points, region links; update route after map generation
|
||||
|
||||
## Data Models
|
||||
Operates on `RouteEntity`, `RoutePointEntity`, and the `route_regions` junction table.
|
||||
|
||||
## Configuration
|
||||
Connection string via constructor.
|
||||
|
||||
## External Integrations
|
||||
PostgreSQL.
|
||||
|
||||
## Security
|
||||
None.
|
||||
|
||||
## Tests
|
||||
No dedicated tests.
|
||||
Reference in New Issue
Block a user