46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
using PARR.API.Contracts.V1;
|
|||
|
|
using PARR.API.Contracts.V1.Responses.Base;
|
|||
|
|
using PARR.API.Contracts.V1.Responses.Statistics;
|
|||
|
|
using PARR.API.Controllers.V1.Base;
|
|||
|
|
using PARR.Constants;
|
|||
|
|
using PARR.DAL.Services.Interfaces;
|
|||
|
|
|
|||
|
|
namespace PARR.API.Controllers.V1.Statistics
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Статистика по приложениям
|
|||
|
|
/// </summary>
|
|||
|
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
|||
|
|
public class StatApplicationController : BaseApiController
|
|||
|
|
{
|
|||
|
|
private readonly IApplicationService applicationService;
|
|||
|
|
|
|||
|
|
public StatApplicationController(IApplicationService applicationService)
|
|||
|
|
{
|
|||
|
|
this.applicationService = applicationService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Статистика синхронизации приложений с АИХИТ за последние сутки
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpGet(ApiRoutes.StatApplication.Get)]
|
|||
|
|
public async Task<IActionResult> Get()
|
|||
|
|
{
|
|||
|
|
var queryDate = DateTimeOffset.UtcNow.AddDays(-1);
|
|||
|
|
|
|||
|
|
var response = new StatApplicationResponse
|
|||
|
|
{
|
|||
|
|
AllApplications = await applicationService.Get().CountAsync(),
|
|||
|
|
CreatedLastDay = await applicationService.Get().CountAsync(t => t.DateCreated >= queryDate),
|
|||
|
|
UpdatedLastDay = await applicationService.Get().CountAsync(t => t.DateModified.HasValue && t.DateModified.Value >= queryDate),
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
return Ok(new Response<StatApplicationResponse>(response, true));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|