Phase 6 (Stufe 3): CopyTrading-Modul auf EF/MySQL umschaltbar
- CopyTradingDbContext (mod_copytrading_* Tabellen) + Design-Time-Factory - EF-Repos: CopyTradeLog, AccountSettings, TrackedTrader, MasterTraderHistory - Neue Repo-Contracts ITrackedTraderRepository + IMasterTraderHistoryRepository (loest die Collection-Inkonsistenz trackers/tracked_traders auf eine Quelle auf) - Mongo-Impls der neuen Contracts (Uebergang) - CopyTradingModule.RegisterServices: Provider-Toggle (MySql via EF / Mongo) - StartupHydrationService + MasterTraderAnalyticsJob nutzen die Repos statt _db - InitialCopyTrading-Migration erstellt und auf MySQL angewendet Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d8cfdbf6be
commit
8101b79cfb
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTrader.Modules.CopyTrading.Persistence.Ef
|
||||
{
|
||||
public class EfMasterTraderHistoryRepository : IMasterTraderHistoryRepository
|
||||
{
|
||||
private readonly IDbContextFactory<CopyTradingDbContext> _factory;
|
||||
|
||||
public EfMasterTraderHistoryRepository(IDbContextFactory<CopyTradingDbContext> factory) => _factory = factory;
|
||||
|
||||
public void EnsureIndexes() { }
|
||||
|
||||
public bool Exists(int traderId, string tokenId, DateTime windowStart, DateTime windowEnd)
|
||||
{
|
||||
using var ctx = _factory.CreateDbContext();
|
||||
return ctx.History.AsNoTracking().Any(x => x.TraderId == traderId && x.TokenId == tokenId
|
||||
&& x.ClosedAt >= windowStart && x.ClosedAt <= windowEnd);
|
||||
}
|
||||
|
||||
public void Insert(MasterTraderHistoryRecord record)
|
||||
{
|
||||
using var ctx = _factory.CreateDbContext();
|
||||
ctx.History.Add(record);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
public List<MasterTraderHistoryRecord> GetByTraderSince(int traderId, DateTime since)
|
||||
{
|
||||
using var ctx = _factory.CreateDbContext();
|
||||
return ctx.History.AsNoTracking().Where(x => x.TraderId == traderId && x.ClosedAt >= since).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user