#498 bug fix
This commit is contained in:
parent
25d36034d3
commit
1d67041247
@ -26,6 +26,9 @@
|
||||
<br />
|
||||
این فرایند در پسزمینه اجرا میشود؛ برای پیگیری وضعیت و درصد پیشرفت به
|
||||
<a asp-area="Admin" asp-page="LongRunningJobs">صفحهٔ کارها</a> مراجعه کنید.
|
||||
<br />
|
||||
گروهبندی سخنوران بر اساس قرن هم پس از پایان درونریزی بهصورت خودکار بازسازی میشود؛ نیازی به
|
||||
اجرای جداگانهٔ آن از صفحهٔ سخنوران نیست.
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
@ -79,13 +79,25 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> RegenerateHalfCenturiesAsync()
|
||||
{
|
||||
return await _RegenerateHalfCenturies(_context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// same as <see cref="RegenerateHalfCenturiesAsync"/>, but against an explicitly-passed
|
||||
/// context instead of the injected <see cref="_context"/> — needed so background jobs
|
||||
/// that construct their own short-lived <see cref="RMuseumDbContext"/> (because the
|
||||
/// request-scoped <see cref="_context"/> may already be disposed by the time a background
|
||||
/// job runs) can call this too, e.g. right after a public-data import finishes.
|
||||
/// </summary>
|
||||
private async Task<RServiceResult<bool>> _RegenerateHalfCenturies(RMuseumDbContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _context.Database.ExecuteSqlRawAsync("DELETE FROM GanjoorCenturyPoet");
|
||||
var oldOnes = await _context.GanjoorCenturies.ToArrayAsync();
|
||||
_context.RemoveRange(oldOnes);
|
||||
await _context.SaveChangesAsync();
|
||||
await context.Database.ExecuteSqlRawAsync("DELETE FROM GanjoorCenturyPoet");
|
||||
var oldOnes = await context.GanjoorCenturies.ToArrayAsync();
|
||||
context.RemoveRange(oldOnes);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
|
||||
var periods = new List<GanjoorCentury>
|
||||
@ -191,7 +203,7 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
};
|
||||
|
||||
var poets = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Published && p.BirthYearInLHijri != 0).OrderBy(p => p.BirthYearInLHijri).ToArrayAsync();
|
||||
var poets = await context.GanjoorPoets.AsNoTracking().Where(p => p.Published && p.BirthYearInLHijri != 0).OrderBy(p => p.BirthYearInLHijri).ToArrayAsync();
|
||||
|
||||
foreach (var poet in poets)
|
||||
{
|
||||
@ -236,8 +248,8 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
if (period.Poets != null)
|
||||
{
|
||||
_context.Add(period);
|
||||
await _context.SaveChangesAsync();
|
||||
context.Add(period);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,6 +88,17 @@ namespace RMuseum.Services.Implementation
|
||||
await ImportPoetFromPublicData(context, source, poetEntry.Id, poetEntry.FullUrl);
|
||||
}
|
||||
|
||||
// GanjooRazor's home page groups poets by century (GetCenturiesAsync /
|
||||
// the "PoetGroups" the view renders) — that grouping is a materialized
|
||||
// table (GanjorCentury/GanjoorCenturyPoet), not computed on the fly, and
|
||||
// newly-imported poets aren't in it until this runs. Skipping this step
|
||||
// is exactly what leaves PoetGroups empty and throws on the home page
|
||||
// (see Index.cshtml.cs's IsDatabaseEffectivelyEmpty check) even though
|
||||
// poets now exist.
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 99, "Regenerating century groupings");
|
||||
await _RegenerateHalfCenturies(context);
|
||||
_memoryCache.Remove("ganjoor/centuries"); // same cache key GetCenturiesAsync/the "periods" endpoint use
|
||||
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user