Skip to content

Commit fad3031

Browse files
author
Doug Schmidt
authored
Merge pull request #299 from DougSchmidt-AI/feature/PF-1405-PointZillaLogPointTimeRange
PF-1405 - Apply consistent summary of points and their time-ranges
2 parents 8ccf9df + aa2c86d commit fad3031

File tree

8 files changed

+30
-13
lines changed

8 files changed

+30
-13
lines changed

TimeSeries/PublicApis/SdkExamples/PointZilla/CsvWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void WritePoints(List<TimeSeriesPoint> points, List<TimeSeriesNote> notes
3232
? Path.Combine(Context.SaveCsvPath, SanitizeFilename($"{timeSeriesIdentifier.Identifier}.{CreatePeriod(Context.SourceQueryFrom, Context.SourceQueryTo)}.csv"))
3333
: Context.SaveCsvPath;
3434

35-
Log.Info($"Saving {"extracted point".ToQuantity(points.Count)} to '{csvPath}' ...");
35+
Log.Info($"Saving {PointSummarizer.Summarize(points, "extracted point")} to '{csvPath}' ...");
3636

3737
var dir = Path.GetDirectoryName(csvPath);
3838

TimeSeries/PublicApis/SdkExamples/PointZilla/PointReaders/CsvReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private List<TimeSeriesPoint> LoadPoints(string path)
9898
}
9999
}
100100

101-
Log.Info($"Loaded {"point".ToQuantity(points.Count)} from '{path}'.");
101+
Log.Info($"Loaded {PointSummarizer.Summarize(points, "point")} from '{path}'.");
102102

103103
return points;
104104
}

TimeSeries/PublicApis/SdkExamples/PointZilla/PointReaders/DbPointsReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public DbPointsReader(Context context)
4646

4747
var notes = LoadNotes(dbClient);
4848

49-
Log.Info($"Loaded {"point".ToQuantity(points.Count)} and {"note".ToQuantity(notes.Count)} from the database source.");
49+
Log.Info($"Loaded {PointSummarizer.Summarize(points)} and {"note".ToQuantity(notes.Count)} from the database source.");
5050

5151
return (points, notes);
5252
}

TimeSeries/PublicApis/SdkExamples/PointZilla/PointReaders/ExternalPointsReader.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private List<TimeSeriesPoint> LoadPointsFromNg(IAquariusClient client)
106106
gapTolerance,
107107
interpolationType);
108108

109-
Log.Info($"Loaded {"point".ToQuantity(points.Count)} and {"note".ToQuantity(Notes.Count)} from {timeSeriesInfo.Identifier}");
109+
Log.Info($"Loaded {PointSummarizer.Summarize(points)} and {"note".ToQuantity(Notes.Count)} from {timeSeriesInfo.Identifier}");
110110

111111
return points;
112112
}
@@ -346,7 +346,7 @@ private List<TimeSeriesPoint> LoadPointsFrom3X(IAquariusClient client)
346346
Notes.AddRange(corrections.Select(c => Convert3XCorrection(utcTimespan, c)));
347347
}
348348

349-
Log.Info($"Loaded {"point".ToQuantity(points.Count)} and {"note".ToQuantity(Notes.Count)} from {Context.SourceTimeSeries.Identifier}");
349+
Log.Info($"Loaded {PointSummarizer.Summarize(points)} and {"note".ToQuantity(Notes.Count)} from {Context.SourceTimeSeries.Identifier}");
350350

351351
return points;
352352
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Aquarius.TimeSeries.Client.ServiceModels.Acquisition;
4+
using Humanizer;
5+
6+
namespace PointZilla.PointReaders
7+
{
8+
public static class PointSummarizer
9+
{
10+
public static string Summarize(List<TimeSeriesPoint> points, string label = "point")
11+
{
12+
var pointExtents = points.Any()
13+
? $" [{points.First().Time} to {points.Last().Time}]"
14+
: "";
15+
16+
return $"{label.ToQuantity(points.Count)}{pointExtents}";
17+
}
18+
}
19+
}

TimeSeries/PublicApis/SdkExamples/PointZilla/PointZilla.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<Compile Include="PointReaders\IPointReader.cs" />
183183
<Compile Include="PointReaders\MetadataLookup.cs" />
184184
<Compile Include="PointReaders\PointReaderBase.cs" />
185+
<Compile Include="PointReaders\PointSummarizer.cs" />
185186
<Compile Include="SaveNotesMode.cs" />
186187
<Compile Include="TextGenerator.cs" />
187188
<Compile Include="TimeSeriesCreator.cs" />

TimeSeries/PublicApis/SdkExamples/PointZilla/PointsAppender.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,11 @@ public void AppendPoints()
8888
}
8989
}
9090

91-
var pointExtents = Points.Any()
92-
? $" [{Points.First().Time} to {Points.Last().Time}]"
93-
: "";
94-
9591
Log.Info(Context.Command == CommandType.DeleteAllPoints
9692
? $"Deleting all existing points from {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
9793
: hasTimeRange
98-
? $"Appending {"point".ToQuantity(Points.Count)} {pointExtents} within TimeRange={GetTimeRange()} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
99-
: $"Appending {"point".ToQuantity(Points.Count)} {pointExtents} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ...");
94+
? $"Appending {PointSummarizer.Summarize(Points)} within TimeRange={GetTimeRange()} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
95+
: $"Appending {PointSummarizer.Summarize(Points)} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ...");
10096

10197
var numberOfPointsAppended = 0;
10298
var numberOfPointsDeleted = 0;
@@ -113,7 +109,7 @@ public void AppendPoints()
113109
if (isBatched)
114110
{
115111
var batchSummary =
116-
$"Appending batch #{batchIndex}: {"point".ToQuantity(batch.Points.Count)} [{batch.Points.First().Time} to {batch.Points.Last().Time}]";
112+
$"Appending batch #{batchIndex}: {PointSummarizer.Summarize(batch.Points)}";
117113

118114
Log.Info( hasTimeRange
119115
? $"{batchSummary} within TimeRange={batch.TimeRange} ..."

TimeSeries/PublicApis/SdkExamples/PointZilla/TextGenerator.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Aquarius.TimeSeries.Client.ServiceModels.Acquisition;
66
using Humanizer;
77
using NodaTime;
8+
using PointZilla.PointReaders;
89
using ServiceStack.Logging;
910

1011
namespace PointZilla
@@ -66,7 +67,7 @@ public List<TimeSeriesPoint> GeneratePoints()
6667
x += symbol.Width * Context.WaveformScalar;
6768
}
6869

69-
Log.Info($"Generated {"vector-text point".ToQuantity(points.Count)}. Scatter-plot X vs Y to read the message.");
70+
Log.Info($"Generated {PointSummarizer.Summarize(points, "vector-text point")}. Scatter-plot X vs Y to read the message.");
7071

7172
return points;
7273
}

0 commit comments

Comments
 (0)