WIP(initial-implementation): parallel batch P2/P3/P5 — code complete, unreviewed

Snapshot of the parallel batch (Phases 2 + 3 + 5) at session pause. Solution does
NOT build cleanly yet — known cross-phase compile issues remain to be resolved
before review. See plans/initial-implementation/PLAN.md "Resume Notes" section
for the exact tomorrow-morning action list.

Phase 2 (Storage):
- Repository interfaces in Marathon.Application/Abstractions
- DateRange, ExportKind, StorageOptions in Marathon.Application/Storage
- EF Core 8 + SQLite (WAL) persistence: 7 entities + configurations + 4 repos
- Hand-written InitialCreate migration (dotnet ef blocked by parallel work)
- ClosedXML ExcelExporter with exact customer-spec wide columns
- PersistenceModule.AddMarathonPersistence DI extension
- Round-trip + export tests (cannot run yet — see cross-phase issues)

Phase 3 (Scraping):
- IOddsScraper, IBetPlacer in Marathon.Application/Abstractions
- ScrapingOptions in Marathon.Infrastructure/Configuration
- MarathonbetScraper with 4 parsers (Upcoming, Live, EventOdds, Results)
- Helpers: ServerTimeProvider, PeriodScopeMapper, OutcomeCodeMapper, MoscowDateParser
- UserAgentRotatorHandler + Polly v8 resilience pipeline
- ScrapingModule.AddMarathonScraping DI extension
- GlobalUsings.cs aliases for EventId / Configuration disambiguation
- Parser tests with trimmed HTML fixtures
- ScrapeResultsAsync interim no-op (Phase 8 will replace via watch-list polling)

Phase 5 (UI shell — killed mid-final-verify, assumed ~95%):
- Marathon.UI populated: MainLayout, App.razor, Pages (Home, Settings),
  Components, Theme (MarathonTheme.cs + Tokens.cs + app.css), Resources
  (SharedResource.{cs,ru.resx,en.resx}), Services (ISettingsWriter), wwwroot
- WPF host: App.xaml(.cs), MainWindow.xaml(.cs), Marathon.Hosts.WpfBlazor.csproj
  with Microsoft.AspNetCore.Components.WebView.Wpf + MudBlazor + Serilog
- appsettings.json + appsettings.Development.json with all sections wired
- bUnit tests: MainLayoutTests, LocaleSwitcherTests, ThemeToggleTests,
  JsonSettingsWriterTests + Support helpers

Cross-phase issues to resolve at next session:
1. Phase 2 repository classes are 'internal' — Phase 3's tests can't reference
   them. Fix: add InternalsVisibleTo to Marathon.Infrastructure.csproj.
2. Phase 5: LocalizationOptions namespace ambiguity (AspNetCore vs Extensions).
3. Phase 5: WpfBlazor Serilog API mismatch.

Reviewer has NOT run on this batch. Move to Phase 4 only after build is green
and a combined parallel-batch reviewer passes.
This commit is contained in:
2026-05-05 01:56:53 +03:00
parent 144c936e90
commit e4d8476782
129 changed files with 8524 additions and 121 deletions
@@ -0,0 +1,187 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marathon.Infrastructure.Migrations;
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Events",
columns: table => new
{
EventCode = table.Column<string>(type: "TEXT", nullable: false),
SportCode = table.Column<int>(type: "INTEGER", nullable: false),
CountryCode = table.Column<string>(type: "TEXT", nullable: false),
LeagueId = table.Column<string>(type: "TEXT", nullable: false),
Category = table.Column<string>(type: "TEXT", nullable: false, defaultValue: ""),
ScheduledAt = table.Column<string>(type: "TEXT", nullable: false),
Side1Name = table.Column<string>(type: "TEXT", nullable: false),
Side2Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.EventCode);
});
migrationBuilder.CreateTable(
name: "Leagues",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
SportCode = table.Column<int>(type: "INTEGER", nullable: false),
Country = table.Column<string>(type: "TEXT", nullable: false),
NameRu = table.Column<string>(type: "TEXT", nullable: false),
NameEn = table.Column<string>(type: "TEXT", nullable: false),
Category = table.Column<string>(type: "TEXT", nullable: false, defaultValue: "")
},
constraints: table =>
{
table.PrimaryKey("PK_Leagues", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sports",
columns: table => new
{
Code = table.Column<int>(type: "INTEGER", nullable: false),
NameRu = table.Column<string>(type: "TEXT", nullable: false),
NameEn = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sports", x => x.Code);
});
migrationBuilder.CreateTable(
name: "Anomalies",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
EventCode = table.Column<string>(type: "TEXT", nullable: false),
DetectedAt = table.Column<string>(type: "TEXT", nullable: false),
Kind = table.Column<int>(type: "INTEGER", nullable: false),
Score = table.Column<decimal>(type: "TEXT", nullable: false),
EvidenceJson = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Anomalies", x => x.Id);
table.ForeignKey(
name: "FK_Anomalies_Events_EventCode",
column: x => x.EventCode,
principalTable: "Events",
principalColumn: "EventCode",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "EventResults",
columns: table => new
{
EventCode = table.Column<string>(type: "TEXT", nullable: false),
Side1Score = table.Column<int>(type: "INTEGER", nullable: false),
Side2Score = table.Column<int>(type: "INTEGER", nullable: false),
WinnerSide = table.Column<int>(type: "INTEGER", nullable: false),
CompletedAt = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EventResults", x => x.EventCode);
table.ForeignKey(
name: "FK_EventResults_Events_EventCode",
column: x => x.EventCode,
principalTable: "Events",
principalColumn: "EventCode",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Snapshots",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
EventCode = table.Column<string>(type: "TEXT", nullable: false),
CapturedAt = table.Column<string>(type: "TEXT", nullable: false),
Source = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Snapshots", x => x.Id);
table.ForeignKey(
name: "FK_Snapshots_Events_EventCode",
column: x => x.EventCode,
principalTable: "Events",
principalColumn: "EventCode",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Bets",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
SnapshotId = table.Column<long>(type: "INTEGER", nullable: false),
Scope = table.Column<int>(type: "INTEGER", nullable: false),
PeriodNumber = table.Column<int>(type: "INTEGER", nullable: true),
Type = table.Column<int>(type: "INTEGER", nullable: false),
Side = table.Column<int>(type: "INTEGER", nullable: false),
Value = table.Column<decimal>(type: "TEXT", nullable: true),
Rate = table.Column<decimal>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bets", x => x.Id);
table.ForeignKey(
name: "FK_Bets_Snapshots_SnapshotId",
column: x => x.SnapshotId,
principalTable: "Snapshots",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// Indexes
migrationBuilder.CreateIndex(
name: "IX_Events_SportCode_ScheduledAt",
table: "Events",
columns: new[] { "SportCode", "ScheduledAt" });
migrationBuilder.CreateIndex(
name: "IX_Events_ScheduledAt",
table: "Events",
column: "ScheduledAt");
migrationBuilder.CreateIndex(
name: "IX_Snapshots_EventCode",
table: "Snapshots",
column: "EventCode");
migrationBuilder.CreateIndex(
name: "IX_Bets_SnapshotId",
table: "Bets",
column: "SnapshotId");
migrationBuilder.CreateIndex(
name: "IX_Anomalies_EventCode",
table: "Anomalies",
column: "EventCode");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(name: "Bets");
migrationBuilder.DropTable(name: "Snapshots");
migrationBuilder.DropTable(name: "EventResults");
migrationBuilder.DropTable(name: "Anomalies");
migrationBuilder.DropTable(name: "Events");
migrationBuilder.DropTable(name: "Leagues");
migrationBuilder.DropTable(name: "Sports");
}
}