Пример #1
0
        public IActionResult GetByPeriod([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation($"Запрос метрик за период c {fromTime:f} по {toTime:f}");

            var response = new ListAllMetricsResponse()
            {
                CpuMetrics      = new List <CPUMetricResponse>(),
                NetworkMetrics  = new List <NetworkMetricResponse>(),
                DotNetMetrics   = new List <DotNetMetricResponse>(),
                HddSpaceMetrics = new List <HddSpaceMetricResponse>(),
                RamMetrics      = new List <RamMetricResponse>()
            };

            response.CpuMetrics = _repository.GetCpuMetricsByPeriod(fromTime, toTime)
                                  .Select(metric => _mapper.Map <CPUMetricResponse>(metric));
            response.NetworkMetrics = _repository.GetNetworkMetricsByPeriod(fromTime, toTime)
                                      .Select(metric => _mapper.Map <NetworkMetricResponse>(metric));
            response.DotNetMetrics = _repository.GetDotNetMetricsByPeriod(fromTime, toTime)
                                     .Select(metric => _mapper.Map <DotNetMetricResponse>(metric));
            response.HddSpaceMetrics = _repository.GetHddSpaceMetricsByPeriod(fromTime, toTime)
                                       .Select(metric => _mapper.Map <HddSpaceMetricResponse>(metric));
            response.RamMetrics = _repository.GetRamMetricsByPeriod(fromTime, toTime)
                                  .Select(metric => _mapper.Map <RamMetricResponse>(metric));

            return(Ok(response));
        }