Search/AdvisoryAI and DAL conversion to EF finishes up. Preparation for microservices consolidation.
This commit is contained in:
@@ -13,14 +13,17 @@ public sealed class CorpusSnapshotRepository : ICorpusSnapshotRepository
|
||||
{
|
||||
private readonly BinaryIndexDbContext _connectionContext;
|
||||
private readonly ILogger<CorpusSnapshotRepository> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
private const int CommandTimeoutSeconds = 30;
|
||||
|
||||
public CorpusSnapshotRepository(
|
||||
BinaryIndexDbContext connectionContext,
|
||||
ILogger<CorpusSnapshotRepository> logger)
|
||||
ILogger<CorpusSnapshotRepository> logger,
|
||||
TimeProvider? timeProvider = null)
|
||||
{
|
||||
_connectionContext = connectionContext;
|
||||
_logger = logger;
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
public async Task<CorpusSnapshot> CreateAsync(CorpusSnapshot snapshot, CancellationToken ct = default)
|
||||
@@ -31,6 +34,7 @@ public sealed class CorpusSnapshotRepository : ICorpusSnapshotRepository
|
||||
var snapshotIdValue = $"{snapshot.Distro}_{snapshot.Release}_{snapshot.Architecture}_{snapshot.CapturedAt:yyyyMMddHHmmss}";
|
||||
|
||||
// Use raw SQL for INSERT ... RETURNING with tenant function
|
||||
var now = _timeProvider.GetUtcNow();
|
||||
var results = await dbContext.CorpusSnapshots
|
||||
.FromSqlInterpolated($"""
|
||||
INSERT INTO binaries.corpus_snapshots (
|
||||
@@ -41,7 +45,7 @@ public sealed class CorpusSnapshotRepository : ICorpusSnapshotRepository
|
||||
{snapshot.Id},
|
||||
binaries_app.require_current_tenant()::uuid,
|
||||
{snapshot.Distro}, {snapshot.Release}, {snapshot.Architecture},
|
||||
{snapshotIdValue}, {snapshot.MetadataDigest}, NOW()
|
||||
{snapshotIdValue}, {snapshot.MetadataDigest}, {now}
|
||||
)
|
||||
RETURNING id, tenant_id, distro, release, architecture, snapshot_id,
|
||||
packages_processed, binaries_indexed, repo_metadata_digest,
|
||||
|
||||
Reference in New Issue
Block a user