Skip to content

Commit 3cdc515

Browse files
author
Doug Schmidt
authored
Merge pull request #306 from DougSchmidt-AI/feature/PF-1425-PointZillaAppendSingleNote
PF-1425 - PointZilla can now append just notes and no points.
2 parents 45b8a21 + 1de1969 commit 3cdc515

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

TimeSeries/PublicApis/SdkExamples/PointZilla/PointsAppender.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public void AppendPoints()
9191
Log.Info(Context.Command == CommandType.DeleteAllPoints
9292
? $"Deleting all existing points from {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
9393
: hasTimeRange
94-
? $"Appending {PointSummarizer.Summarize(Points)} within TimeRange={GetTimeRange()} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
95-
: $"Appending {PointSummarizer.Summarize(Points)} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ...");
94+
? $"Appending {PointSummarizer.Summarize(Points)} and {"note".ToQuantity(Notes.Count)} within TimeRange={GetTimeRange()} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ..."
95+
: $"Appending {PointSummarizer.Summarize(Points)} and {"note".ToQuantity(Notes.Count)} to {timeSeries.Identifier} ({timeSeries.TimeSeriesType}) ...");
9696

9797
var numberOfPointsAppended = 0;
9898
var numberOfPointsDeleted = 0;
@@ -296,14 +296,23 @@ private TimeSeriesAppendStatus AppendPointBatch(IAquariusClient client, TimeSeri
296296
Points = points
297297
});
298298
}
299-
else
299+
else if (points.Any() || !Notes.Any())
300300
{
301301
appendResponse = client.Acquisition.Post(new PostTimeSeriesAppend
302302
{
303303
UniqueId = timeSeries.UniqueId,
304304
Points = points
305305
});
306306
}
307+
else
308+
{
309+
// We didn't have any basic points to append, but we do have notes to append.
310+
// So just fake a completed status so we can move on to appending the notes.
311+
return new TimeSeriesAppendStatus
312+
{
313+
AppendStatus = AppendStatusCode.Completed,
314+
};
315+
}
307316
}
308317

309318
return client.Acquisition.RequestAndPollUntilComplete(
@@ -424,7 +433,6 @@ private List<TimeSeriesNote> LoadNotes()
424433
.ToList();
425434
}
426435

427-
428436
private Interval GetTimeRange()
429437
{
430438
if (Context.Command == CommandType.DeleteAllPoints)
@@ -437,7 +445,12 @@ private Interval GetTimeRange()
437445
return Context.TimeRange.Value;
438446

439447
if (!Points.Any())
448+
{
449+
if (Notes.Any())
450+
return new Interval(Instant.MinValue, Instant.MaxValue);
451+
440452
throw new ExpectedException($"Can't infer a time-range from an empty points list. Please set the /{nameof(Context.TimeRange)} option explicitly.");
453+
}
441454

442455
return new Interval(
443456
// ReSharper disable once PossibleInvalidOperationException

0 commit comments

Comments
 (0)