#266 removing recitation approved mistakes upon replacing the recitation
This commit is contained in:
parent
c9c883cd23
commit
190456d59d
@ -1833,11 +1833,18 @@
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.AcceptReportedErrorAsync(System.Int32)">
|
||||
<summary>
|
||||
accepts a reported error for recitations and notify the reporter and recitation owner (and deletes the report)
|
||||
accepts a reported error for recitations, change status of the recitation to rejected and notify the reporter and recitation owner (and deletes the report)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.AddReportToTheApprovedMistakesAsync(RMuseum.Models.GanjoorAudio.ViewModels.RecitationErrorReportViewModel)">
|
||||
<summary>
|
||||
accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report)
|
||||
</summary>
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.UpVoteRecitationAsync(System.Int32)">
|
||||
<summary>
|
||||
up vote a recitation
|
||||
@ -12662,6 +12669,13 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.AddReportToTheApprovedMistakesAsync(RMuseum.Models.GanjoorAudio.ViewModels.RecitationErrorReportViewModel)">
|
||||
<summary>
|
||||
accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report)
|
||||
</summary>
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.ComputePoemRecitationsOrdersAsync(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
compute poem recitations order
|
||||
@ -13070,11 +13084,18 @@
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.AcceptReportedErrorAsync(System.Int32)">
|
||||
<summary>
|
||||
accepts a reported error for recitations and notify the reporter and recitation owner (and deletes the report)
|
||||
accepts a reported error for recitations, change status of the recitation to rejected and notify the reporter and recitation owner (and deletes the report)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.AddReportToTheApprovedMistakesAsync(RMuseum.Models.GanjoorAudio.ViewModels.RecitationErrorReportViewModel)">
|
||||
<summary>
|
||||
accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report)
|
||||
</summary>
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.ComputePoemRecitationsOrdersAsync(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
compute poem recitations order
|
||||
|
||||
@ -897,6 +897,15 @@ namespace RMuseum.Services.Implementationa
|
||||
existing.FileLastUpdated = session.UploadEndTime;
|
||||
existing.AudioSyncStatus = AudioSyncStatus.SynchronizedOrRejected;
|
||||
context.Recitations.Update(existing);
|
||||
|
||||
bool recomputeOrders = false;
|
||||
var mistakes = await context.RecitationApprovedMistakes.Where(m => m.RecitationId == existing.Id).ToListAsync();
|
||||
if(mistakes.Count > 0)
|
||||
{
|
||||
context.RemoveRange(mistakes);
|
||||
recomputeOrders = true;
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
await new RNotificationService(context).PushNotification
|
||||
@ -907,6 +916,11 @@ namespace RMuseum.Services.Implementationa
|
||||
$"میتوانید با مراجعه به <a href=\"https://ganjoor.net/?p={existing.GanjoorPostId}\">این صفحه</a> وضعیت آن را بررسی کنید."
|
||||
);
|
||||
|
||||
if(recomputeOrders)
|
||||
{
|
||||
await _ComputePoemRecitationsOrdersAsync(context, existing.GanjoorPostId, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1938,11 +1952,16 @@ namespace RMuseum.Services.Implementationa
|
||||
/// <param name="update"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<RecitationOrderingViewModel[]>> ComputePoemRecitationsOrdersAsync(int poemId, bool update = true)
|
||||
{
|
||||
return await _ComputePoemRecitationsOrdersAsync(_context, poemId, update);
|
||||
}
|
||||
|
||||
public async Task<RServiceResult<RecitationOrderingViewModel[]>> _ComputePoemRecitationsOrdersAsync(RMuseumDbContext context, int poemId, bool update)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recitations =
|
||||
await _context.Recitations
|
||||
await context.Recitations
|
||||
.Where(r => r.ReviewStatus == AudioReviewStatus.Approved && r.GanjoorPostId == poemId)
|
||||
.OrderBy(r => r.Id) //this causes the oldest recirations to become the first one
|
||||
.ToListAsync();
|
||||
@ -1956,9 +1975,9 @@ namespace RMuseum.Services.Implementationa
|
||||
{
|
||||
RecitationId = recitation.Id,
|
||||
EarlynessAdvantage = recitations.Count - 1 - i,
|
||||
UpVotes = await _context.RecitationUserUpVotes.AsNoTracking().Where(r => r.RecitationId == recitation.Id && r.UserId != recitation.OwnerId)
|
||||
UpVotes = await context.RecitationUserUpVotes.AsNoTracking().Where(r => r.RecitationId == recitation.Id && r.UserId != recitation.OwnerId)
|
||||
.CountAsync(),
|
||||
Mistakes = await _context.RecitationApprovedMistakes.AsNoTracking().Where(m => m.RecitationId == recitation.Id).SumAsync(m => m.NumberOfLinesAffected)
|
||||
Mistakes = await context.RecitationApprovedMistakes.AsNoTracking().Where(m => m.RecitationId == recitation.Id).SumAsync(m => m.NumberOfLinesAffected)
|
||||
};
|
||||
|
||||
|
||||
@ -1981,13 +2000,13 @@ namespace RMuseum.Services.Implementationa
|
||||
|
||||
if (update)
|
||||
{
|
||||
_context.Update(recitations[i]);
|
||||
context.Update(recitations[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (update)
|
||||
await _context.SaveChangesAsync();
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
|
||||
return new RServiceResult<RecitationOrderingViewModel[]>(scores.ToArray());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user