feat: WIP connections query endpoint

This commit is contained in:
2024-12-26 14:41:24 +01:00
parent 63bbf80ced
commit 9f5099c819
7 changed files with 81 additions and 32 deletions

View File

@@ -7,7 +7,7 @@ public class PuzzleRepository(ConnectionsContext _db)
{
private readonly ConnectionsContext _db = _db;
public async Task<ConnectionsPuzzle?> GetPuzzleByDateAsync(string printDate, bool includeSolutions = true)
public async Task<ConnectionsPuzzle?> GetConnectionsByDateAsync(string printDate, bool includeSolutions = true)
{
// query for the puzzle
var query = _db.ConnectionsPuzzles.AsNoTracking();
@@ -27,12 +27,12 @@ public class PuzzleRepository(ConnectionsContext _db)
return null;
}
await EnhancePuzzleWithDatesAsync(puzzle);
await EnhanceConnectionsWithDatesAsync(puzzle);
return puzzle;
}
public async Task<IEnumerable<ConnectionsPuzzle>> GetAllPuzzlesAsync(bool includeSolutions = true)
public async Task<IEnumerable<ConnectionsPuzzle>> GetAllConnectionsAsync(bool includeSolutions = true)
{
// query all, ordered by print date
var query = _db.ConnectionsPuzzles
@@ -49,13 +49,13 @@ public class PuzzleRepository(ConnectionsContext _db)
foreach (var puzzle in result)
{
await EnhancePuzzleWithDatesAsync(puzzle);
await EnhanceConnectionsWithDatesAsync(puzzle);
}
return result;
}
private async Task EnhancePuzzleWithDatesAsync(ConnectionsPuzzle puzzle)
private async Task EnhanceConnectionsWithDatesAsync(ConnectionsPuzzle puzzle)
{
string? previousPuzzleDate = await _db.ConnectionsPuzzles.AsNoTracking()
.Where(x => x.PrintDate.CompareTo(puzzle.PrintDate) < 0)