Skip to content

Commit 99aa84a

Browse files
committed
Corrected so that we still will be able to process reports, even when they are not stored due to the report limit
1 parent 227d7c9 commit 99aa84a

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

src/Server/Coderr.Server.ReportAnalyzer.Abstractions/Incidents/ReportAddedToIncident.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,10 @@ protected ReportAddedToIncident()
5454
/// Received report.
5555
/// </summary>
5656
public ReportDTO Report { get; private set; }
57+
58+
/// <summary>
59+
/// Report have been stored (i.e. we do not have too many reports yet).
60+
/// </summary>
61+
public bool? IsStored { get; set; }
5762
}
5863
}

src/Server/Coderr.Server.ReportAnalyzer/Inbound/Handlers/Reports/ReportAnalyzer.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public async Task Analyze(IMessageContext context, ErrorReportEntity report)
8484
return;
8585
}
8686

87+
var storeReport = true;
8788
var applicationVersion = GetVersionFromReport(report);
8889
var isReOpened = false;
8990
var firstLine = report.GenerateHashCodeIdentifier();
@@ -145,19 +146,26 @@ public async Task Analyze(IMessageContext context, ErrorReportEntity report)
145146
{
146147
_repository.UpdateIncident(incident);
147148
_logger.Debug($"Report count is more than 25. Ignoring report for incident {incident.Id}.");
148-
return;
149+
storeReport = false;
150+
}
151+
else
152+
{
153+
incident.LastStoredReportUtc = DateTime.UtcNow;
154+
_repository.UpdateIncident(incident);
149155
}
150156

151-
incident.LastStoredReportUtc = DateTime.UtcNow;
152-
_repository.UpdateIncident(incident);
153157
}
154158

155159
if (!string.IsNullOrWhiteSpace(report.EnvironmentName))
156160
_repository.SaveEnvironmentName(incident.Id, report.EnvironmentName);
157161

158162
report.IncidentId = incident.Id;
159-
_repository.CreateReport(report);
160-
_logger.Debug($"saving report {report.Id} for incident {incident.Id}");
163+
164+
if (storeReport)
165+
{
166+
_repository.CreateReport(report);
167+
_logger.Debug($"saving report {report.Id} for incident {incident.Id}");
168+
}
161169

162170
await _repository.StoreReportStats(new ReportMapping()
163171
{
@@ -181,11 +189,16 @@ await _repository.StoreReportStats(new ReportMapping()
181189
sw.Start();
182190
var e = new ReportAddedToIncident(summary, ConvertToCoreReport(report, applicationVersion), isReOpened)
183191
{
184-
IsNewIncident = isNewIncident
192+
IsNewIncident = isNewIncident,
193+
IsStored = storeReport
185194
};
186195
await context.SendAsync(e);
187196

188-
await context.SendAsync(new ProcessInboundContextCollections());
197+
if (storeReport)
198+
{
199+
await context.SendAsync(new ProcessInboundContextCollections());
200+
201+
}
189202

190203
if (sw.ElapsedMilliseconds > 200)
191204
_logger.Debug($"PublishAsync took {sw.ElapsedMilliseconds}");

src/Server/Coderr.Server.ReportAnalyzer/Similarities/Handlers/UpdateSimilaritiesFromNewReport.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public UpdateSimilaritiesFromNewReport(ISimilarityRepository similarityRepositor
3939
/// </returns>
4040
public async Task HandleAsync(IMessageContext context, ReportAddedToIncident e)
4141
{
42+
if (e.IsStored != true)
43+
{
44+
return;
45+
}
46+
4247
_logger.Debug("Updating similarities " + e.Incident.Id);
4348
var adapters = _adapterRepository.GetAdapters();
4449
var sw2 = new Stopwatch();

src/Server/Coderr.Server.Web/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
},
2121
"include": [
22-
"ClientApp/**/*.ts", "wwwroot/js/service-worker.js", "../Coderr.Server.ReportAnalyzer/UserNotifications/BrowserNotificationConfig.cs"
22+
"ClientApp/**/*.ts",
23+
"wwwroot/js/service-worker.js"
2324
],
2425
"exclude": [
2526
"bin",

0 commit comments

Comments
 (0)