mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 02:01: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.Common.Enums;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
@@ -8,26 +7,26 @@ namespace SatelliteProvider.DataAccess.Repositories;
|
||||
|
||||
public class RegionRepository : IRegionRepository
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly ILogger<RegionRepository> _logger;
|
||||
private const string ColumnList = @"id, latitude, longitude, size_meters as SizeMeters,
|
||||
zoom_level as ZoomLevel, status,
|
||||
csv_file_path as CsvFilePath, summary_file_path as SummaryFilePath,
|
||||
tiles_downloaded as TilesDownloaded, tiles_reused as TilesReused,
|
||||
stitch_tiles as StitchTiles,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt";
|
||||
|
||||
public RegionRepository(string connectionString, ILogger<RegionRepository> logger)
|
||||
private readonly string _connectionString;
|
||||
|
||||
public RegionRepository(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RegionEntity?> GetByIdAsync(Guid id)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
const string sql = @"
|
||||
SELECT id, latitude, longitude, size_meters as SizeMeters,
|
||||
zoom_level as ZoomLevel, status,
|
||||
csv_file_path as CsvFilePath, summary_file_path as SummaryFilePath,
|
||||
tiles_downloaded as TilesDownloaded, tiles_reused as TilesReused,
|
||||
stitch_tiles as StitchTiles,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt
|
||||
FROM regions
|
||||
const string sql = $@"
|
||||
SELECT {ColumnList}
|
||||
FROM regions
|
||||
WHERE id = @Id";
|
||||
|
||||
var region = await connection.QuerySingleOrDefaultAsync<RegionEntity>(sql, new { Id = id });
|
||||
@@ -37,14 +36,9 @@ public class RegionRepository : IRegionRepository
|
||||
public async Task<IEnumerable<RegionEntity>> GetByStatusAsync(RegionStatus status)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
const string sql = @"
|
||||
SELECT id, latitude, longitude, size_meters as SizeMeters,
|
||||
zoom_level as ZoomLevel, status,
|
||||
csv_file_path as CsvFilePath, summary_file_path as SummaryFilePath,
|
||||
tiles_downloaded as TilesDownloaded, tiles_reused as TilesReused,
|
||||
stitch_tiles as StitchTiles,
|
||||
created_at as CreatedAt, updated_at as UpdatedAt
|
||||
FROM regions
|
||||
const string sql = $@"
|
||||
SELECT {ColumnList}
|
||||
FROM regions
|
||||
WHERE status = @Status
|
||||
ORDER BY created_at ASC";
|
||||
|
||||
@@ -96,4 +90,3 @@ public class RegionRepository : IRegionRepository
|
||||
return await connection.ExecuteAsync(sql, new { Id = id });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user