From 0f08d71ddb98dcbf783f8cba6aa8cd83879557db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Tue, 10 Aug 2021 16:37:13 +0500 Subject: [PATCH] better names for db entities --- AsbCloudInfrastructure/ReportDataSourcePgCloud.cs | 8 ++++---- AsbCloudInfrastructure/Services/AnalyticsService.cs | 4 ++-- AsbCloudInfrastructure/Services/EventService.cs | 6 +++--- AsbCloudInfrastructure/Services/MessageService.cs | 12 ++++++------ AsbCloudInfrastructure/Services/ReportService.cs | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index 1810194b..ddaca704 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -14,7 +14,7 @@ namespace AsbSaubReport private readonly int? idTelemetry; private readonly WellInfoReport info; - private readonly Dictionary events; + private readonly Dictionary events; private readonly Dictionary users; private readonly Dictionary categories = new Dictionary { @@ -38,7 +38,7 @@ namespace AsbSaubReport if (idTelemetry is null) throw new ArgumentException($"Well {idWell} doesn't contain telemetry", nameof(idWell)); - events = context.Events + events = context.TelemetryEvents .Where(e => e.IdTelemetry == idTelemetry) .ToDictionary(e => e.IdEvent, e => e); @@ -59,7 +59,7 @@ namespace AsbSaubReport public AnalyzeResult Analyze() { - var messagesQuery = from item in context.Messages + var messagesQuery = from item in context.TelemetryMessages where item.IdTelemetry == idTelemetry select item; @@ -114,7 +114,7 @@ namespace AsbSaubReport }; public IQueryable GetMessages(DateTime begin, DateTime end) - => from item in context.Messages + => from item in context.TelemetryMessages where item.IdTelemetry == idTelemetry && item.Date >= begin && item.Date <= end diff --git a/AsbCloudInfrastructure/Services/AnalyticsService.cs b/AsbCloudInfrastructure/Services/AnalyticsService.cs index f67c2a35..efdc74ec 100644 --- a/AsbCloudInfrastructure/Services/AnalyticsService.cs +++ b/AsbCloudInfrastructure/Services/AnalyticsService.cs @@ -162,7 +162,7 @@ namespace AsbCloudInfrastructure.Services var operations = (from a in db.TelemetryAnalysis where a.IdTelemetry == telemetryId && a.UnixDate > unixBegin && a.UnixDate < unixEnd - join o in db.Operations on a.IdOperation equals o.Id + join o in db.TelemetryOperations on a.IdOperation equals o.Id group a by new { a.IdOperation, o.Name } into g select new TelemetryOperationDurationDto { @@ -188,7 +188,7 @@ namespace AsbCloudInfrastructure.Services var operations = (from a in db.TelemetryAnalysis where a.IdTelemetry == telemetryId - join o in db.Operations on a.IdOperation equals o.Id + join o in db.TelemetryOperations on a.IdOperation equals o.Id group a by new { Interval = Math.Floor((a.UnixDate - workBeginSeconds + timezoneOffset) / intervalSeconds), diff --git a/AsbCloudInfrastructure/Services/EventService.cs b/AsbCloudInfrastructure/Services/EventService.cs index 867abd38..150a6d60 100644 --- a/AsbCloudInfrastructure/Services/EventService.cs +++ b/AsbCloudInfrastructure/Services/EventService.cs @@ -10,12 +10,12 @@ namespace AsbCloudInfrastructure.Services public class EventService : IEventService { private readonly ITelemetryService telemetryService; - private readonly CacheTable cacheEvents; + private readonly CacheTable cacheEvents; public EventService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService) { this.telemetryService = telemetryService; - cacheEvents = cacheDb.GetCachedTable((AsbCloudDbContext)db); + cacheEvents = cacheDb.GetCachedTable((AsbCloudDbContext)db); } public void Upsert(string uid, IEnumerable dtos) @@ -25,7 +25,7 @@ namespace AsbCloudInfrastructure.Services var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid); - var entities = dtos.Select(dto => new Event + var entities = dtos.Select(dto => new TelemetryEvent { IdEvent = dto.Id, IdTelemetry = telemetryId, diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs index 908f1f1a..40bfd9f6 100644 --- a/AsbCloudInfrastructure/Services/MessageService.cs +++ b/AsbCloudInfrastructure/Services/MessageService.cs @@ -14,14 +14,14 @@ namespace AsbCloudInfrastructure.Services { private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; - private readonly CacheTable cacheEvents; + private readonly CacheTable cacheEvents; private readonly CacheTable cacheTUsers; public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService) { this.db = db; this.telemetryService = telemetryService; - cacheEvents = cacheDb.GetCachedTable((AsbCloudDbContext)db); + cacheEvents = cacheDb.GetCachedTable((AsbCloudDbContext)db); cacheTUsers = cacheDb.GetCachedTable((AsbCloudDbContext)db); } @@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services if (!events.Any()) return null; - var query = db.Messages.Where(m => m.IdTelemetry == telemetryId); + var query = db.TelemetryMessages.Where(m => m.IdTelemetry == telemetryId); if ((categoryids?.Any() == true) || !string.IsNullOrEmpty(searchString)) { @@ -114,7 +114,7 @@ namespace AsbCloudInfrastructure.Services if (telemetryId is null) return null; - var (From, To) = db.GetDatesRange((int)telemetryId); + var (From, To) = db.GetDatesRange((int)telemetryId); return new DatesRangeDto { From = From, To = To }; } @@ -128,10 +128,10 @@ namespace AsbCloudInfrastructure.Services foreach (var dto in dtos) { - var entity = dto.Adapt(); + var entity = dto.Adapt(); entity.Id = 0; entity.IdTelemetry = telemetryId; - db.Messages.Add(entity); + db.TelemetryMessages.Add(entity); } db.SaveChanges(); diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index 87ffcf02..98af558d 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -119,7 +119,7 @@ namespace AsbCloudInfrastructure.Services var datesRange = (from d in db.DataSaubBases where d.IdTelemetry == telemetryId select d.Date).Union( - from m in db.Messages + from m in db.TelemetryMessages where m.IdTelemetry == telemetryId select m.Date).DefaultIfEmpty().GroupBy(g => true) .Select(g => new