#478 section edits stats
This commit is contained in:
parent
bb148db97b
commit
6be3b54e7f
@ -15930,6 +15930,29 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IContributionStatsService.GetApprovedSectionEditsGroupedByDateAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.Guid})">
|
||||
<summary>
|
||||
approved section edits daily
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IContributionStatsService.GetApprovedSectionEditsGroupedByUserAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.DateTime},System.Nullable{System.Guid})">
|
||||
<summary>
|
||||
approved section edits grouped by user
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="day"></param>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IContributionStatsService.GetApprrovedSedtionEditsSummedUpStatsAsync">
|
||||
<summary>
|
||||
summed up stats of approved secton corrections
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IDonationService">
|
||||
<summary>
|
||||
donation service
|
||||
@ -18859,6 +18882,29 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ContributionStatsService.GetApprovedSectionEditsGroupedByDateAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.Guid})">
|
||||
<summary>
|
||||
approved section edits daily
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ContributionStatsService.GetApprovedSectionEditsGroupedByUserAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.DateTime},System.Nullable{System.Guid})">
|
||||
<summary>
|
||||
approved section edits grouped by user
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="day"></param>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ContributionStatsService.GetApprrovedSedtionEditsSummedUpStatsAsync">
|
||||
<summary>
|
||||
summed up stats of approved secton corrections
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:RMuseum.Services.Implementation.ContributionStatsService._context">
|
||||
<summary>
|
||||
Database Context
|
||||
|
||||
@ -33,5 +33,29 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<SummedUpViewModel>> GetApprrovedEditsSummedUpStatsAsync();
|
||||
|
||||
/// <summary>
|
||||
/// approved section edits daily
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GroupedByDateViewModel[] Tracks)>> GetApprovedSectionEditsGroupedByDateAsync(PagingParameterModel paging, Guid? userId);
|
||||
|
||||
/// <summary>
|
||||
/// approved section edits grouped by user
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="day"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GroupedByUserViewModel[] Tracks)>> GetApprovedSectionEditsGroupedByUserAsync(PagingParameterModel paging, DateTime? day, Guid? userId);
|
||||
|
||||
/// <summary>
|
||||
/// summed up stats of approved secton corrections
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<SummedUpViewModel>> GetApprrovedSedtionEditsSummedUpStatsAsync();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,6 +127,120 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// approved section edits daily
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GroupedByDateViewModel[] Tracks)>> GetApprovedSectionEditsGroupedByDateAsync(PagingParameterModel paging, Guid? userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GroupedByDateViewModel[] Tracks)>(
|
||||
await QueryablePaginator<GroupedByDateViewModel>.Paginate(
|
||||
_context.GanjoorPoemSectionCorrections
|
||||
.Where(c =>
|
||||
c.AffectedThePoem == true
|
||||
&&
|
||||
(userId == null || c.UserId == userId)
|
||||
)
|
||||
.GroupBy(a => a.Date.Date)
|
||||
.Select(a => new GroupedByDateViewModel()
|
||||
{
|
||||
Date = a.Key.Date.ToString(),
|
||||
Number = a.Count(),
|
||||
}).OrderByDescending(s => s.Date)
|
||||
, paging));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GroupedByDateViewModel[] Tracks)>((null, null), e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// approved section edits grouped by user
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="day"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GroupedByUserViewModel[] Tracks)>> GetApprovedSectionEditsGroupedByUserAsync(PagingParameterModel paging, DateTime? day, Guid? userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GroupedByUserViewModel[] Tracks)>(
|
||||
await QueryablePaginator<GroupedByUserViewModel>.Paginate(
|
||||
_context.GanjoorPoemSectionCorrections
|
||||
.Join
|
||||
(
|
||||
_context.Users,
|
||||
correction => correction.UserId,
|
||||
user => user.Id,
|
||||
(correction, user) => new
|
||||
{
|
||||
correction.Date,
|
||||
UserId = user.Id,
|
||||
UserName = user.NickName,
|
||||
correction.AffectedThePoem,
|
||||
}
|
||||
)
|
||||
.Where(f =>
|
||||
f.AffectedThePoem
|
||||
&&
|
||||
(day == null || f.Date.Date == day) && (userId == null || f.UserId == userId))
|
||||
.GroupBy(a => new { a.UserId, a.UserName }).Select(a => new GroupedByUserViewModel()
|
||||
{
|
||||
UserId = a.Key.UserId,
|
||||
UserName = a.Key.UserName,
|
||||
Number = a.Count(),
|
||||
}).OrderByDescending(s => s.Number)
|
||||
, paging));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GroupedByUserViewModel[] Tracks)>((null, null), e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// summed up stats of approved secton corrections
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<SummedUpViewModel>> GetApprrovedSedtionEditsSummedUpStatsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<SummedUpViewModel>
|
||||
(
|
||||
new SummedUpViewModel()
|
||||
{
|
||||
Days = await _context.GanjoorPoemSectionCorrections
|
||||
.Where(f => f.AffectedThePoem
|
||||
)
|
||||
.GroupBy(f => f.Date.Date).CountAsync(),
|
||||
TotalCount = await _context.GanjoorPoemSectionCorrections
|
||||
|
||||
.Where(f => f.AffectedThePoem
|
||||
)
|
||||
.CountAsync(),
|
||||
UserIds = await _context.GanjoorPoemSectionCorrections
|
||||
.Where(f => f.AffectedThePoem
|
||||
)
|
||||
.GroupBy(f => f.UserId).CountAsync(),
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new RServiceResult<SummedUpViewModel>(null, e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Database Context
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user