diff --git a/plans/initial-implementation/PLAN.md b/plans/initial-implementation/PLAN.md index ccdc1ff..b01217d 100644 --- a/plans/initial-implementation/PLAN.md +++ b/plans/initial-implementation/PLAN.md @@ -64,10 +64,10 @@ parameter configurable. |---|---|---|---|---|---| | Phase 0: Scraping spike | backend | ✅ Done | ⚠️ Pass with notes (Sonnet) | ⏭️ N/A (research) | ✅ 070e34b | | Phase 1: Solution + Domain | backend | ✅ Done | ⚠️ Pass with notes (Sonnet) | ✅ Build OK + 96/96 Domain tests | ✅ 61114ea | -| Phase 2: Storage | backend | 🔨 Code done, not committed | ⬜ Pending | ⏭️ Big Bang (own code 0/0) | ⬜ WIP | -| Phase 3: Scraping | backend | 🔨 Code done, not committed | ⬜ Pending | ⏭️ Big Bang (own code 0/0) | ⬜ WIP | +| Phase 2: Storage | backend | ✅ Done | ⚠️ Pass with notes (Sonnet, combined batch) | ✅ Build OK + 77/77 Infra tests | ✅ batch (e4d8476…686550d…+) | +| Phase 3: Scraping | backend | ✅ Done | ⚠️ Pass with notes (Sonnet, combined batch) | ✅ Build OK + 77/77 Infra tests | ✅ batch (e4d8476…686550d…+) | | Phase 4: Application + Workers | backend | ⬜ Not Started | ⬜ | ⏭️ Big Bang | ⬜ | -| Phase 5: Host + Theme + i18n | frontend | 🔨 ~95% (killed mid-final-verify) | ⬜ Pending | ⏭️ Big Bang | ⬜ WIP | +| Phase 5: Host + Theme + i18n | frontend | ✅ Done | ⚠️ Pass with notes (Sonnet, combined batch) | ✅ Build OK + 11/11 UI tests | ✅ batch (e4d8476…686550d…+) | | Phase 6: Event browsing UI | frontend | ⬜ Not Started | ⬜ | ⏭️ Big Bang | ⬜ | | Phase 7: Anomaly detection | fullstack | ⬜ Not Started | ⬜ | ⏭️ Big Bang | ⬜ | | Phase 8: Results loader | fullstack | ⬜ Not Started | ⬜ | ⏭️ Big Bang | ⬜ | diff --git a/src/Marathon.Infrastructure/Export/ExcelExporter.cs b/src/Marathon.Infrastructure/Export/ExcelExporter.cs index ff3f313..39b5ef5 100644 --- a/src/Marathon.Infrastructure/Export/ExcelExporter.cs +++ b/src/Marathon.Infrastructure/Export/ExcelExporter.cs @@ -32,8 +32,8 @@ internal sealed class ExcelExporter : IExcelExporter var snapshotEntities = await _db.Snapshots.AsNoTracking() .Include(s => s.Bets) .Include(s => s.Event) - .Where(s => string.Compare(s.CapturedAt, fromStr, StringComparison.Ordinal) >= 0 - && string.Compare(s.CapturedAt, toStr, StringComparison.Ordinal) <= 0) + .Where(s => s.CapturedAt.CompareTo(fromStr) >= 0 + && s.CapturedAt.CompareTo(toStr) <= 0) .ToListAsync(ct); // Convert to domain objects for processing diff --git a/src/Marathon.Infrastructure/Persistence/Repositories/EventRepository.cs b/src/Marathon.Infrastructure/Persistence/Repositories/EventRepository.cs index 5ecf349..dfb6794 100644 --- a/src/Marathon.Infrastructure/Persistence/Repositories/EventRepository.cs +++ b/src/Marathon.Infrastructure/Persistence/Repositories/EventRepository.cs @@ -30,9 +30,12 @@ internal sealed class EventRepository : IEventRepository var fromStr = range.From.ToString("O"); var toStr = range.To.ToString("O"); + // EF Core SQLite cannot translate string.Compare(...) with StringComparison; it can + // translate the relational operators on string columns (which use BINARY/ordinal + // collation by default in SQLite — correct for ISO 8601). var entities = await _db.Events.AsNoTracking() - .Where(e => string.Compare(e.ScheduledAt, fromStr, StringComparison.Ordinal) >= 0 - && string.Compare(e.ScheduledAt, toStr, StringComparison.Ordinal) <= 0) + .Where(e => e.ScheduledAt.CompareTo(fromStr) >= 0 + && e.ScheduledAt.CompareTo(toStr) <= 0) .ToListAsync(ct); return entities.Select(Mapping.ToDomain).ToList().AsReadOnly(); diff --git a/src/Marathon.Infrastructure/Persistence/Repositories/SnapshotRepository.cs b/src/Marathon.Infrastructure/Persistence/Repositories/SnapshotRepository.cs index f7195e6..f9dbb2a 100644 --- a/src/Marathon.Infrastructure/Persistence/Repositories/SnapshotRepository.cs +++ b/src/Marathon.Infrastructure/Persistence/Repositories/SnapshotRepository.cs @@ -43,8 +43,8 @@ internal sealed class SnapshotRepository : ISnapshotRepository var entities = await _db.Snapshots.AsNoTracking() .Include(s => s.Bets) .Where(s => s.EventCode == eventId.Value - && string.Compare(s.CapturedAt, fromStr, StringComparison.Ordinal) >= 0 - && string.Compare(s.CapturedAt, toStr, StringComparison.Ordinal) <= 0) + && s.CapturedAt.CompareTo(fromStr) >= 0 + && s.CapturedAt.CompareTo(toStr) <= 0) .ToListAsync(ct); return entities.Select(Mapping.ToDomain).ToList().AsReadOnly(); diff --git a/src/Marathon.Infrastructure/Scraping/Parsers/EventListingParserBase.cs b/src/Marathon.Infrastructure/Scraping/Parsers/EventListingParserBase.cs index a7bc47e..6e0ca95 100644 --- a/src/Marathon.Infrastructure/Scraping/Parsers/EventListingParserBase.cs +++ b/src/Marathon.Infrastructure/Scraping/Parsers/EventListingParserBase.cs @@ -36,7 +36,7 @@ public abstract class EventListingParserBase CancellationToken ct) { var serverTime = ServerTimeProvider.ExtractServerTime(html) - ?? new DateTimeOffset(DateTimeOffset.UtcNow.UtcDateTime, MoscowOffset); + ?? DateTimeOffset.UtcNow.ToOffset(MoscowOffset); var config = AngleSharpConfig.Default; using var context = BrowsingContext.New(config); diff --git a/src/Marathon.Infrastructure/Scraping/Parsers/EventOddsParser.cs b/src/Marathon.Infrastructure/Scraping/Parsers/EventOddsParser.cs index fc353c3..580c046 100644 --- a/src/Marathon.Infrastructure/Scraping/Parsers/EventOddsParser.cs +++ b/src/Marathon.Infrastructure/Scraping/Parsers/EventOddsParser.cs @@ -69,7 +69,7 @@ public sealed partial class EventOddsParser : IEventOddsParser ArgumentNullException.ThrowIfNull(html); var capturedAt = _serverTime.ExtractServerTime(html) - ?? new DateTimeOffset(DateTimeOffset.UtcNow.UtcDateTime, MoscowOffset); + ?? DateTimeOffset.UtcNow.ToOffset(MoscowOffset); var config = AngleSharpConfig.Default; using var context = BrowsingContext.New(config); diff --git a/src/Marathon.Infrastructure/Scraping/Parsers/ResultsParser.cs b/src/Marathon.Infrastructure/Scraping/Parsers/ResultsParser.cs index 610e71b..1961bc4 100644 --- a/src/Marathon.Infrastructure/Scraping/Parsers/ResultsParser.cs +++ b/src/Marathon.Infrastructure/Scraping/Parsers/ResultsParser.cs @@ -101,7 +101,7 @@ public sealed partial class ResultsParser : IResultsParser if (string.IsNullOrWhiteSpace(eventIdRaw)) return null; - var completedAt = new DateTimeOffset(DateTimeOffset.UtcNow.UtcDateTime, MoscowOffset); + var completedAt = DateTimeOffset.UtcNow.ToOffset(MoscowOffset); return new EventResult( new DomainEventId(eventIdRaw), diff --git a/src/Marathon.Infrastructure/Scraping/Parsers/ServerTimeProvider.cs b/src/Marathon.Infrastructure/Scraping/Parsers/ServerTimeProvider.cs index a2ffa5d..6006086 100644 --- a/src/Marathon.Infrastructure/Scraping/Parsers/ServerTimeProvider.cs +++ b/src/Marathon.Infrastructure/Scraping/Parsers/ServerTimeProvider.cs @@ -9,9 +9,11 @@ namespace Marathon.Infrastructure.Scraping.Parsers; /// public sealed partial class ServerTimeProvider : IServerTimeProvider { - // Matches: serverTime:"YYYY,MM,DD,HH,mm,ss" + // Matches both forms observed on marathonbet.by: + // serverTime:"YYYY,MM,DD,HH,mm,ss" (bare key) + // "serverTime":"YYYY,MM,DD,HH,mm,ss" (JSON-quoted key — actual prod format) [GeneratedRegex( - @"serverTime\s*:\s*""(\d{4}),(\d{1,2}),(\d{1,2}),(\d{1,2}),(\d{1,2}),(\d{1,2})""", + @"""?serverTime""?\s*:\s*""(\d{4}),(\d{1,2}),(\d{1,2}),(\d{1,2}),(\d{1,2}),(\d{1,2})""", RegexOptions.CultureInvariant)] private static partial Regex ServerTimeRegex(); diff --git a/tests/Marathon.Infrastructure.Tests/Fixtures/marathonbet/event-football-sample.html b/tests/Marathon.Infrastructure.Tests/Fixtures/marathonbet/event-football-sample.html index dd1331f..0b017c3 100644 --- a/tests/Marathon.Infrastructure.Tests/Fixtures/marathonbet/event-football-sample.html +++ b/tests/Marathon.Infrastructure.Tests/Fixtures/marathonbet/event-football-sample.html @@ -29,46 +29,56 @@ - -
| + 1.65 + | ++ 4.10 + | ++ 5.70 + | +
|
+ (-1.0) + 2.04 + |
+
+ (+1.0) + 1.82 + |
+ |
|
+ (2.5) + 1.92 + |
+
+ (2.5) + 1.92 + |
+ |
| 1.80 | +3.60 | +4.20 | +
| 2.10 | +2.80 | +3.50 | +