From 75d75cd2650f0d2a87b2c11dbabd5497f20aa841 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Wed, 26 Mar 2025 19:41:40 +0330 Subject: [PATCH] #478 GetApprrovedEditsSummedUpStatsAsync --- .../Generic/ViewModels/SummedUpViewModel.cs | 23 +++++++++++ RMuseum/RMuseum.xml | 32 ++++++++++++++++ RMuseum/Services/IContributionStatsService.cs | 6 +++ .../ContributionStatsService.cs | 38 ++++++++++++++++++- 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 RMuseum/Models/Generic/ViewModels/SummedUpViewModel.cs diff --git a/RMuseum/Models/Generic/ViewModels/SummedUpViewModel.cs b/RMuseum/Models/Generic/ViewModels/SummedUpViewModel.cs new file mode 100644 index 00000000..e7b79a93 --- /dev/null +++ b/RMuseum/Models/Generic/ViewModels/SummedUpViewModel.cs @@ -0,0 +1,23 @@ +namespace RMuseum.Models.Generic.ViewModels +{ + /// + /// summed up view model + /// + public class SummedUpViewModel + { + /// + /// Number of days + /// + public int Days { get; set; } + + /// + /// Total number + /// + public int TotalCount { get; set; } + + /// + /// Total Number of UserIds + /// + public int UserIds { get; set; } + } +} diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index d3a28941..6e4a720c 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -13417,6 +13417,26 @@ user name + + + summed up view model + + + + + Number of days + + + + + Total number + + + + + Total Number of UserIds + + Import Job @@ -15871,6 +15891,12 @@ + + + summed up stats of approved poem corrections + + + donation service @@ -18801,6 +18827,12 @@ + + + summed up stats of approved poem corrections + + + Database Context diff --git a/RMuseum/Services/IContributionStatsService.cs b/RMuseum/Services/IContributionStatsService.cs index c02619c9..06aca864 100644 --- a/RMuseum/Services/IContributionStatsService.cs +++ b/RMuseum/Services/IContributionStatsService.cs @@ -34,5 +34,11 @@ namespace RMuseum.Services /// Task> GetApprovedEditsGroupedByUserAsync(PagingParameterModel paging, DateTime? day, Guid? userId); + /// + /// summed up stats of approved poem corrections + /// + /// + Task> GetApprrovedEditsSummedUpStatsAsync(); + } } diff --git a/RMuseum/Services/Implementation/ContributionStatsService.cs b/RMuseum/Services/Implementation/ContributionStatsService.cs index 2b6f5d93..9f1bc240 100644 --- a/RMuseum/Services/Implementation/ContributionStatsService.cs +++ b/RMuseum/Services/Implementation/ContributionStatsService.cs @@ -1,4 +1,5 @@ -using RMuseum.DbContext; +using Microsoft.EntityFrameworkCore; +using RMuseum.DbContext; using RMuseum.Models.Generic.ViewModels; using RSecurityBackend.Models.Generic; using RSecurityBackend.Services.Implementation; @@ -134,6 +135,41 @@ namespace RMuseum.Services.Implementation } } + /// + /// summed up stats of approved poem corrections + /// + /// + public async Task> GetApprrovedEditsSummedUpStatsAsync() + { + try + { + return new RServiceResult + ( + new SummedUpViewModel() + { + Days = await _context.GanjoorPoemCorrections + .Where(f => f.AffectedThePoem + ) + .GroupBy(f => f.Date.Date).CountAsync(), + TotalCount = await _context.GanjoorPoemCorrections + + .Where(f => f.AffectedThePoem + ) + .CountAsync(), + UserIds = await _context.GanjoorPoemCorrections + .Where(f => f.AffectedThePoem + ) + .GroupBy(f => f.UserId).CountAsync(), + } + ); + + } + catch (Exception e) + { + return new RServiceResult(null, e.ToString()); + } + } + /// /// Database Context ///