mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 09:21:14 +00:00
[AZ-376] [AZ-378] [AZ-379] [AZ-380] Repo cleanup: dead code, logger discipline, ColumnList consts
Batch 23 of refactor 03-code-quality-refactoring (4 tasks, 5 SP):
- AZ-376 (C23): Delete unused FindExistingTileAsync from
ITileRepository / TileRepository. No callers; method also took the
obsolete `version` arg removed by C06/AZ-357.
- AZ-378 (C25): Repository _logger discipline.
TileRepository.GetTilesByRegionAsync now emits LogWarning when the
query exceeds SlowQueryThresholdMs (500 ms). RegionRepository and
RouteRepository drop the unused ILogger<TRepo> field, parameter, and
using; Program.cs DI registrations updated.
- AZ-379 (C26): Extract `private const string ColumnList` per repo
(TileRepository, RegionRepository, RouteRepository); SELECTs use
$@"SELECT {ColumnList} FROM ..." (C# 10+ const interpolation).
INSERT/UPDATE/DELETE unchanged; route_points single-site SELECT left
inline.
- AZ-380 (C27): Delete dead alias GeoUtils.CalculatePolygonDiagonalDistance.
Tests: +9 new (RepositoryRefactorTests x8, GeoUtilsRefactorTests x1)
covering each AC via reflection / file-content assertions; pattern
mirrors ToolingConfigurationTests (b22) and AcceptanceCriteriaRT2Tests
(b19). Unit suite 181 -> 190, all green. dotnet format clean.
Code review: PASS_WITH_WARNINGS (3 Low findings, all informational or
out-of-scope for this batch). See
_docs/03_implementation/reviews/batch_23_review.md.
Cumulative review counter 2/3; next K=3 review fires after batch 24.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
|
||||
@@ -7,28 +6,28 @@ namespace SatelliteProvider.DataAccess.Repositories;
|
||||
|
||||
public class RouteRepository : IRouteRepository
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly ILogger<RouteRepository> _logger;
|
||||
private const string ColumnList = @"id, name, description, region_size_meters as RegionSizeMeters,
|
||||
zoom_level as ZoomLevel, total_distance_meters as TotalDistanceMeters,
|
||||
total_points as TotalPoints, request_maps as RequestMaps,
|
||||
maps_ready as MapsReady, create_tiles_zip as CreateTilesZip,
|
||||
csv_file_path as CsvFilePath,
|
||||
summary_file_path as SummaryFilePath, stitched_image_path as StitchedImagePath,
|
||||
tiles_zip_path as TilesZipPath,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt";
|
||||
|
||||
public RouteRepository(string connectionString, ILogger<RouteRepository> logger)
|
||||
private readonly string _connectionString;
|
||||
|
||||
public RouteRepository(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RouteEntity?> GetByIdAsync(Guid id)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
const string sql = @"
|
||||
SELECT id, name, description, region_size_meters as RegionSizeMeters,
|
||||
zoom_level as ZoomLevel, total_distance_meters as TotalDistanceMeters,
|
||||
total_points as TotalPoints, request_maps as RequestMaps,
|
||||
maps_ready as MapsReady, create_tiles_zip as CreateTilesZip,
|
||||
csv_file_path as CsvFilePath,
|
||||
summary_file_path as SummaryFilePath, stitched_image_path as StitchedImagePath,
|
||||
tiles_zip_path as TilesZipPath,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt
|
||||
FROM routes
|
||||
const string sql = $@"
|
||||
SELECT {ColumnList}
|
||||
FROM routes
|
||||
WHERE id = @Id";
|
||||
|
||||
return await connection.QuerySingleOrDefaultAsync<RouteEntity>(sql, new { Id = id });
|
||||
@@ -146,16 +145,9 @@ public class RouteRepository : IRouteRepository
|
||||
public async Task<IEnumerable<RouteEntity>> GetRoutesWithPendingMapsAsync()
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
const string sql = @"
|
||||
SELECT id, name, description, region_size_meters as RegionSizeMeters,
|
||||
zoom_level as ZoomLevel, total_distance_meters as TotalDistanceMeters,
|
||||
total_points as TotalPoints, request_maps as RequestMaps,
|
||||
maps_ready as MapsReady, create_tiles_zip as CreateTilesZip,
|
||||
csv_file_path as CsvFilePath,
|
||||
summary_file_path as SummaryFilePath, stitched_image_path as StitchedImagePath,
|
||||
tiles_zip_path as TilesZipPath,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt
|
||||
FROM routes
|
||||
const string sql = $@"
|
||||
SELECT {ColumnList}
|
||||
FROM routes
|
||||
WHERE request_maps = true AND maps_ready = false";
|
||||
|
||||
return await connection.QueryAsync<RouteEntity>(sql);
|
||||
@@ -185,4 +177,3 @@ public class RouteRepository : IRouteRepository
|
||||
return grouped;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user