Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 0d376eb

Browse files
author
Scott Bommarito
authored
Hotfix: fix StatusAggregator AggregationProvider query (#608)
1 parent a5e0608 commit 0d376eb

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/StatusAggregator/Factory/AggregationProvider.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,31 @@ public async Task<TAggregationEntity> GetAsync(ParsedIncident input)
4343

4444
var possiblePath = _aggregationPathProvider.Get(input);
4545
// Find an aggregation to link to
46-
var possibleAggregations = _table
46+
var possibleAggregationsQuery = _table
4747
.CreateQuery<TAggregationEntity>()
4848
.Where(e =>
4949
// The aggregation must affect the same path
5050
e.AffectedComponentPath == possiblePath &&
5151
// The aggregation must begin before or at the same time
52-
e.StartTime <= input.StartTime &&
53-
// The aggregation must cover the same time period
54-
(
55-
// If the aggregation is active, it covers the same time period
56-
e.IsActive ||
57-
// Otherwise, if the child is not active, and the aggregation ends after it ends, it covers the same time period
58-
(!input.IsActive && e.EndTime >= input.EndTime)
59-
))
52+
e.StartTime <= input.StartTime);
53+
54+
// The aggregation must cover the same time period
55+
if (input.IsActive)
56+
{
57+
// An active input can only be linked to an active aggregation
58+
possibleAggregationsQuery = possibleAggregationsQuery
59+
.Where(e => e.IsActive);
60+
}
61+
else
62+
{
63+
// An inactive input can be linked to an active aggregation or an inactive aggregation that ends after it
64+
possibleAggregationsQuery = possibleAggregationsQuery
65+
.Where(e =>
66+
e.IsActive ||
67+
e.EndTime >= input.EndTime);
68+
}
69+
70+
var possibleAggregations = possibleAggregationsQuery
6071
.ToList();
6172

6273
_logger.LogInformation("Found {AggregationCount} possible aggregations to link entity to with path {AffectedComponentPath}.", possibleAggregations.Count(), possiblePath);

src/StatusAggregator/Factory/IncidentFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task<IncidentEntity> CreateAsync(ParsedIncident input)
4242
input.Id,
4343
groupEntity,
4444
affectedPath,
45-
(ComponentStatus)input.AffectedComponentStatus,
45+
input.AffectedComponentStatus,
4646
input.StartTime,
4747
input.EndTime);
4848

0 commit comments

Comments
 (0)