feat(API): восстановлена статистика по шаблонам после перехода на Job
This commit is contained in:
@@ -32,66 +32,66 @@ namespace PARR.API.Controllers.V1.Statistics
|
|||||||
this.calendarService = calendarService;
|
this.calendarService = calendarService;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// Статистика по шаблонам
|
/// Статистика по шаблонам
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <returns></returns>
|
/// <returns></returns>
|
||||||
//[HttpGet(ApiRoutes.StatTemplate.Get)]
|
[HttpGet(ApiRoutes.StatTemplate.Get)]
|
||||||
//public async Task<IActionResult> Get()
|
public async Task<IActionResult> Get()
|
||||||
//{
|
{
|
||||||
// var response = new StatTemplateResponse
|
var response = new StatTemplateResponse
|
||||||
// {
|
{
|
||||||
// ActivateScheduleCount = await templateService.Get().CountAsync(t => t.IsActiveSchedule),
|
ActivateScheduleCount = await templateService.Get().CountAsync(t => t.IsActiveSchedule),
|
||||||
// ActivateTemplateCount = await templateService.Get().CountAsync(t => t.IsActiveTemplate),
|
ActivateTemplateCount = await templateService.Get().CountAsync(t => t.IsActiveTemplate),
|
||||||
// TemplateAgentCount = await templateService.Get().Include(t => t.ApplicationsInWork).CountAsync(t => t.ApplicationsInWork!.IsAgent),
|
TemplateAgentCount = await templateService.Get().Include(t => t.Job).ThenInclude(t=>t.Group).CountAsync(t => t.Job!.Group!.IsAgent),
|
||||||
// TemplateCount = await templateService.Get().CountAsync(),
|
TemplateCount = await templateService.Get().CountAsync(),
|
||||||
// SyncEsppScheduleCount = await templateService.Get().Include(t => t.RobotConfigurations).CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.ScheduleOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok)),
|
SyncEsppScheduleCount = await templateService.Get().Include(t => t.RobotConfigurations).CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.ScheduleOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok)),
|
||||||
// SyncEsppTemplatesCount = await templateService.Get().Include(t => t.RobotConfigurations).CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.TemplateOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok))
|
SyncEsppTemplatesCount = await templateService.Get().Include(t => t.RobotConfigurations).CountAsync(t => t.RobotConfigurations.Any(c => c.RobotCode == (int)RobotsEnum.TemplateOrder && c.TaskStatusCode == (int)TaskStatusEnum.Ok))
|
||||||
// };
|
};
|
||||||
|
|
||||||
// return Ok(new Response<StatTemplateResponse>(response, true));
|
return Ok(new Response<StatTemplateResponse>(response, true));
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// Получить статистику созданных шаблонов (расписаний) в БД ПАРР
|
/// Получить статистику созданных шаблонов (расписаний) в БД ПАРР
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="timeZoneQuery"></param>
|
/// <param name="timeZoneQuery"></param>
|
||||||
///// <param name="startPeriodDays"></param>
|
/// <param name="startPeriodDays"></param>
|
||||||
///// <returns></returns>
|
/// <returns></returns>
|
||||||
//[HttpGet(ApiRoutes.StatTemplate.GetForPeriod)]
|
[HttpGet(ApiRoutes.StatTemplate.GetForPeriod)]
|
||||||
//public async Task<IActionResult> GetForPeriod([FromQuery] TimeZoneOffsetClient timeZoneQuery, [FromQuery] int startPeriodDays = 3)
|
public async Task<IActionResult> GetForPeriod([FromQuery] TimeZoneOffsetClient timeZoneQuery, [FromQuery] int startPeriodDays = 3)
|
||||||
//{
|
{
|
||||||
// var endPeriod = calendarService.GetDateWithTimeZoneOffset(DateTimeOffset.UtcNow, timeZoneQuery.TimeZoneOffsetHours);
|
var endPeriod = calendarService.GetDateWithTimeZoneOffset(DateTimeOffset.UtcNow, timeZoneQuery.TimeZoneOffsetHours);
|
||||||
// var startPeriod = endPeriod.AddDays(-startPeriodDays);
|
var startPeriod = endPeriod.AddDays(-startPeriodDays);
|
||||||
|
|
||||||
// var query = templateService.Get()
|
var query = templateService.Get()
|
||||||
// .Where(t =>
|
.Where(t =>
|
||||||
// t.DateCreated.DateTime.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date >= startPeriod.Date
|
t.DateCreated.DateTime.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date >= startPeriod.Date
|
||||||
// && t.DateCreated.DateTime.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date <= endPeriod.Date
|
&& t.DateCreated.DateTime.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date <= endPeriod.Date
|
||||||
// ).GroupBy(t => t.DateCreated.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date)
|
).GroupBy(t => t.DateCreated.AddHours(timeZoneQuery.TimeZoneOffsetHours).Date)
|
||||||
// .Select(t => new
|
.Select(t => new
|
||||||
// {
|
{
|
||||||
// Date = t.Key,
|
Date = t.Key,
|
||||||
// CreatedObjs = t.Count()
|
CreatedObjs = t.Count()
|
||||||
// });
|
});
|
||||||
|
|
||||||
// var result = await query.ToListAsync();
|
var result = await query.ToListAsync();
|
||||||
|
|
||||||
// var daysList = calendarService.GetDatesForPeriod(startPeriod, endPeriod);
|
var daysList = calendarService.GetDatesForPeriod(startPeriod, endPeriod);
|
||||||
|
|
||||||
// var response = new List<StatTemplatePeriodResponse>();
|
var response = new List<StatTemplatePeriodResponse>();
|
||||||
|
|
||||||
// daysList.ForEach(date => response.Add(new StatTemplatePeriodResponse
|
daysList.ForEach(date => response.Add(new StatTemplatePeriodResponse
|
||||||
// {
|
{
|
||||||
// Date = date,
|
Date = date,
|
||||||
// CreatedTemplatesCount = result.FirstOrDefault(t => DateOnly.FromDateTime(t.Date) == date)?.CreatedObjs ?? 0
|
CreatedTemplatesCount = result.FirstOrDefault(t => DateOnly.FromDateTime(t.Date) == date)?.CreatedObjs ?? 0
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
// response = response.OrderBy(t => t.Date).ToList();
|
response = response.OrderBy(t => t.Date).ToList();
|
||||||
|
|
||||||
// return Ok(new Response<List<StatTemplatePeriodResponse>>(response, true));
|
return Ok(new Response<List<StatTemplatePeriodResponse>>(response, true));
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user