refactor(architecture): harden module boundaries
Some checks failed
ci / release-gate (push) Has been cancelled
Some checks failed
ci / release-gate (push) Has been cancelled
This commit is contained in:
@@ -42,19 +42,19 @@ internal sealed class ContentImportService(
|
||||
Guid jobId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var job = await dbContext.ContentImportJobs.AsNoTracking()
|
||||
var job = await questionBankPersistence.ContentImportJobs.AsNoTracking()
|
||||
.Where(item => item.TenantId == actor.TenantId && item.Id == jobId)
|
||||
.Select(item => ToJobItem(item))
|
||||
.SingleOrDefaultAsync(cancellationToken);
|
||||
if (job is null) throw new ContentManagementException("Import job was not found.", "import_job_not_found");
|
||||
|
||||
var items = await dbContext.ContentImportItems.AsNoTracking()
|
||||
var items = await questionBankPersistence.ContentImportItems.AsNoTracking()
|
||||
.Where(item => item.TenantId == actor.TenantId && item.JobId == jobId)
|
||||
.OrderBy(item => item.RowNo)
|
||||
.Take(MaxLimit)
|
||||
.Select(item => ToImportItem(item))
|
||||
.ToArrayAsync(cancellationToken);
|
||||
var issues = await dbContext.ContentImportIssues.AsNoTracking()
|
||||
var issues = await questionBankPersistence.ContentImportIssues.AsNoTracking()
|
||||
.Where(issue => issue.TenantId == actor.TenantId && issue.JobId == jobId)
|
||||
.OrderBy(issue => issue.RowNo)
|
||||
.ThenBy(issue => issue.CreatedAt)
|
||||
@@ -80,7 +80,7 @@ internal sealed class ContentImportService(
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
await AssertImportJobAsync(actor.TenantId, jobId, cancellationToken);
|
||||
var issues = await dbContext.ContentImportIssues.AsNoTracking()
|
||||
var issues = await questionBankPersistence.ContentImportIssues.AsNoTracking()
|
||||
.Where(item => item.TenantId == actor.TenantId && item.JobId == jobId)
|
||||
.OrderBy(item => item.RowNo)
|
||||
.ThenBy(item => item.CreatedAt)
|
||||
@@ -104,7 +104,7 @@ internal sealed class ContentImportService(
|
||||
Guid jobId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var job = await dbContext.ContentImportJobs.SingleOrDefaultAsync(
|
||||
var job = await questionBankPersistence.ContentImportJobs.SingleOrDefaultAsync(
|
||||
item => item.TenantId == actor.TenantId && item.Id == jobId,
|
||||
cancellationToken);
|
||||
if (job is null) throw new ContentManagementException("Import job was not found.", "import_job_not_found");
|
||||
@@ -128,7 +128,7 @@ internal sealed class ContentImportService(
|
||||
counts
|
||||
}
|
||||
});
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
await unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return new ImportPostCheckResult(job.Id, job.ErrorCount == 0 ? "passed" : "warning", counts, []);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ internal sealed class ContentImportService(
|
||||
Guid jobId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var job = await dbContext.ContentImportJobs.AsNoTracking().SingleOrDefaultAsync(
|
||||
var job = await questionBankPersistence.ContentImportJobs.AsNoTracking().SingleOrDefaultAsync(
|
||||
item => item.TenantId == actor.TenantId && item.Id == jobId,
|
||||
cancellationToken);
|
||||
if (job is null) throw new ContentManagementException("Import job was not found.", "import_job_not_found");
|
||||
@@ -189,7 +189,7 @@ internal sealed class ContentImportService(
|
||||
StartedAt = execute ? DateTimeOffset.UtcNow : null,
|
||||
FinishedAt = execute ? DateTimeOffset.UtcNow : null
|
||||
};
|
||||
dbContext.ContentImportJobs.Add(job);
|
||||
questionBankPersistence.ContentImportJobs.Add(job);
|
||||
|
||||
var importItems = new List<ContentImportItem>();
|
||||
var rowNo = 1;
|
||||
@@ -217,7 +217,7 @@ internal sealed class ContentImportService(
|
||||
importItems.Add(importItem);
|
||||
}
|
||||
|
||||
dbContext.ContentImportItems.AddRange(importItems);
|
||||
questionBankPersistence.ContentImportItems.AddRange(importItems);
|
||||
job.Summary = JsonSerializer.SerializeToElement(new
|
||||
{
|
||||
mode = execute ? "execute" : "preview",
|
||||
@@ -225,7 +225,7 @@ internal sealed class ContentImportService(
|
||||
note = "Synchronous direct migration import skeleton; async worker will be introduced later."
|
||||
});
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
await unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return new SimpleImportResult(
|
||||
ToJobItem(job),
|
||||
importItems.Select(ToImportItem).ToArray(),
|
||||
|
||||
Reference in New Issue
Block a user