stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace StellaOps.Provcache.Postgres;
|
||||
|
||||
public sealed partial class PostgresEvidenceChunkRepository
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task<ChunkManifest?> GetManifestAsync(
|
||||
string proofRoot,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(proofRoot);
|
||||
|
||||
// Get metadata without loading blobs
|
||||
var chunks = await _context.EvidenceChunks
|
||||
.Where(e => e.ProofRoot == proofRoot)
|
||||
.OrderBy(e => e.ChunkIndex)
|
||||
.Select(e => new
|
||||
{
|
||||
e.ChunkId,
|
||||
e.ChunkIndex,
|
||||
e.ChunkHash,
|
||||
e.BlobSize,
|
||||
e.ContentType,
|
||||
e.CreatedAt
|
||||
})
|
||||
.AsNoTracking()
|
||||
.ToListAsync(cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (chunks.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var metadata = chunks
|
||||
.Select(c => new ChunkMetadata
|
||||
{
|
||||
ChunkId = c.ChunkId,
|
||||
Index = c.ChunkIndex,
|
||||
Hash = c.ChunkHash,
|
||||
Size = c.BlobSize,
|
||||
ContentType = c.ContentType
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return new ChunkManifest
|
||||
{
|
||||
ProofRoot = proofRoot,
|
||||
TotalChunks = chunks.Count,
|
||||
TotalSize = chunks.Sum(c => (long)c.BlobSize),
|
||||
Chunks = metadata,
|
||||
GeneratedAt = _timeProvider.GetUtcNow()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user