using AsbCloudApp.Data; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers { [Route("api/admin/telemetry")] [ApiController] [Authorize] public class AdminTelemetryController : CrudController> { private readonly ITelemetryService telemetryService; public AdminTelemetryController(ICrudService service, ITelemetryService telemetryService) : base(service) { service.Includes.Add("Well"); this.telemetryService = telemetryService; } [HttpGet] [Route("/reduntentUids")] public IActionResult GetRedundentRemoteUids() { var result = telemetryService.GetDuplicateRemoteUids().Select(i => new { i.Key, ids = i.Ids }); return Ok(result); } /// /// merge telemetries /// /// [HttpPost] [Route("/merge/{idFrom}/{idTo}")] public async Task MergeTelemetriesAsync(int idFrom, int idTo, CancellationToken token = default) { var count = await telemetryService.MergeAsync(idFrom, idTo, token) .ConfigureAwait(false); return Ok(count); } } }