From 026fbea52904ddb82f30d43576637b9882b819d6 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Fri, 14 May 2021 09:58:02 +0500 Subject: [PATCH] =?UTF-8?q?CS2-6:=20=D0=92=20TelemetryTracker=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D1=8B=20=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Services/ITelemetryTracker.cs | 4 ++-- AsbCloudInfrastructure/Services/TelemetryTracker.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AsbCloudApp/Services/ITelemetryTracker.cs b/AsbCloudApp/Services/ITelemetryTracker.cs index ac582a52..878f88dd 100644 --- a/AsbCloudApp/Services/ITelemetryTracker.cs +++ b/AsbCloudApp/Services/ITelemetryTracker.cs @@ -4,7 +4,7 @@ namespace AsbCloudApp.Services { public interface ITelemetryTracker { - void SaveRequest(string id); - IEnumerable GetRequests(); + void SaveRequestDate(string uid); + IEnumerable GetRequestUids(); } } diff --git a/AsbCloudInfrastructure/Services/TelemetryTracker.cs b/AsbCloudInfrastructure/Services/TelemetryTracker.cs index 21e172c1..a2b5d08b 100644 --- a/AsbCloudInfrastructure/Services/TelemetryTracker.cs +++ b/AsbCloudInfrastructure/Services/TelemetryTracker.cs @@ -10,20 +10,20 @@ namespace AsbCloudInfrastructure.Services private IDictionary requests = new Dictionary(); private readonly TimeSpan timeout = TimeSpan.FromMinutes(6); - private void DeleteOldRequests() + private void DeleteOldRequestDates() { requests = requests.Where(dValue => (DateTime.Now - dValue.Value) < timeout).ToDictionary(dValue => dValue.Key, dValue => dValue.Value); } - public void SaveRequest(string id) + public void SaveRequestDate(string uid) { - requests[id] = DateTime.Now; - DeleteOldRequests(); + requests[uid] = DateTime.Now; + DeleteOldRequestDates(); } - public IEnumerable GetRequests() + public IEnumerable GetRequestUids() { - DeleteOldRequests(); + DeleteOldRequestDates(); return requests.Keys; } }