From ec5038cdf0be9a35f09b311630815f2b6e592d8a Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Mon, 22 Jul 2024 16:26:32 +1000 Subject: [PATCH] =?UTF-8?q?feat(api):=20StatRobotState=20=D0=B2=20=D0=91?= =?UTF-8?q?=D0=94=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=8B=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20ip=20=D1=80=D0=BE=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V1/Responses/Statistics/StatRobotStateResponse.cs | 2 ++ .../V1/Statistics/StatRobotStateController.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs b/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs index 7695dacf..5735cf55 100644 --- a/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs +++ b/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs @@ -5,5 +5,7 @@ public DateTimeOffset Date { get; set; } public int IsUp { get; set; } + + public string? Ip { get; set; } } } diff --git a/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs b/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs index 561e8b63..54b0a469 100644 --- a/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs +++ b/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs @@ -9,6 +9,7 @@ using PARR.API.Contracts.V1.Requests.Queries; using PARR.API.Contracts.V1.Responses.Base; using PARR.API.Contracts.V1.Responses.Statistics; using PARR.API.Controllers.V1.Base; +using PARR.API.Services.Interfaces; using PARR.API.Settings; using PARR.Constants; using PARR.DAL.InfluxDbServices; @@ -26,18 +27,21 @@ namespace PARR.API.Controllers.V1.Statistics private readonly IValidator validator; private readonly InfluxDbSettings influxDbSettings; private readonly MonitoringSettings monitoringSettings; + private readonly IClientService clientService; public StatRobotStateController( IInfluxDbService influxDbService, IValidator validator, InfluxDbSettings influxDbSettings, - MonitoringSettings monitoringSettings + MonitoringSettings monitoringSettings, + IClientService clientService ) { this.influxDbService = influxDbService; this.validator = validator; this.influxDbSettings = influxDbSettings; this.monitoringSettings = monitoringSettings; + this.clientService = clientService; } @@ -81,7 +85,8 @@ namespace PARR.API.Controllers.V1.Statistics table.Records.Select(record => new StatRobotStateResponse { Date = (DateTimeOffset)record.GetTimeInDateTime(), - IsUp = int.Parse(record.GetValue()?.ToString() ?? "0") + IsUp = int.Parse(record.GetValue()?.ToString() ?? "0"), + Ip = record.GetValueByKey("ip")?.ToString() }) ); }, influxDbSettings.Robots!.Token); @@ -112,6 +117,7 @@ namespace PARR.API.Controllers.V1.Statistics { var point = PointData.Measurement("robots") .Tag("robot", request.Robot.ToString()) + .Tag("ip", clientService.GetClientIp()?.ToString()) //.Field("robot", (int)request.Robot) .Field("isUp", 1) .Timestamp(DateTime.UtcNow, WritePrecision.Ns);