From c1a78f0f33ee7d370b16bb87ae346ffd974aede3 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 11 Dec 2022 08:47:41 +0330 Subject: [PATCH] show only user corrections in correction review --- RMuseum/Controllers/GanjoorController.cs | 7 ++++--- RMuseum/RMuseum.xml | 15 ++++++++++----- RMuseum/Services/IGanjoorService.cs | 6 ++++-- RMuseum/Services/Implementation/GanjoorService.cs | 15 +++++++++++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index dee84307..619f3fe4 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -1292,6 +1292,7 @@ namespace RMuseum.Controllers /// get next unreviewed correction /// /// + /// /// [HttpGet] [Route("poem/correction/next")] @@ -1299,14 +1300,14 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCorrectionViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task GetNextUnreviewedCorrection(int skip = 0) + public async Task GetNextUnreviewedCorrection(int skip = 0, bool onlyUserCorrections = false) { RServiceResult res = - await _ganjoorService.GetNextUnreviewedCorrection(skip); + await _ganjoorService.GetNextUnreviewedCorrection(skip, onlyUserCorrections); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); - var resCount = await _ganjoorService.GetUnreviewedCorrectionCount(); + var resCount = await _ganjoorService.GetUnreviewedCorrectionCount(onlyUserCorrections); if (!string.IsNullOrEmpty(resCount.ExceptionString)) return BadRequest(resCount.ExceptionString); diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 70583eb1..c7f6be0d 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -1269,11 +1269,12 @@ - + get next unreviewed correction + @@ -12176,17 +12177,19 @@ - + get next unreviewed correction + - + unreview correction count + @@ -15348,17 +15351,19 @@ - + get next unreviewed correction + - + unreview correction count + diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index 804486e7..2aec0cca 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -248,14 +248,16 @@ namespace RMuseum.Services /// get next unreviewed correction /// /// + /// /// - Task> GetNextUnreviewedCorrection(int skip); + Task> GetNextUnreviewedCorrection(int skip, bool onlyUserCorrections); /// /// unreview correction count /// + /// /// - Task> GetUnreviewedCorrectionCount(); + Task> GetUnreviewedCorrectionCount(bool onlyUserCorrections); /// /// moderate poem correction diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index c0bc42f3..b1c8d5cc 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -2063,11 +2063,15 @@ namespace RMuseum.Services.Implementation /// get next unreviewed correction /// /// + /// /// - public async Task> GetNextUnreviewedCorrection(int skip) + public async Task> GetNextUnreviewedCorrection(int skip, bool onlyUserCorrections) { + string systemEmail = $"{Configuration.GetSection("Ganjoor")["SystemEmail"]}"; + var systemUserId = (Guid)(await _appUserService.FindUserByEmail(systemEmail)).Result.Id; + var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User) - .Where(c => c.Reviewed == false) + .Where(c => c.Reviewed == false && (onlyUserCorrections == false || c.UserId != systemUserId)) .OrderBy(c => c.Id) .Skip(skip) .FirstOrDefaultAsync(); @@ -2108,11 +2112,14 @@ namespace RMuseum.Services.Implementation /// /// unreview correction count /// + /// /// - public async Task> GetUnreviewedCorrectionCount() + public async Task> GetUnreviewedCorrectionCount(bool onlyUserCorrections) { + string systemEmail = $"{Configuration.GetSection("Ganjoor")["SystemEmail"]}"; + var systemUserId = (Guid)(await _appUserService.FindUserByEmail(systemEmail)).Result.Id; return new RServiceResult(await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText) - .Where(c => c.Reviewed == false) + .Where(c => c.Reviewed == false && (onlyUserCorrections == false || c.UserId != systemUserId)) .CountAsync()); }