diff --git a/TeslaSolarCharger/Client/Components/HiddenErrorsComponent.razor b/TeslaSolarCharger/Client/Components/HiddenErrorsComponent.razor
index 37f84e8ab..64217058c 100644
--- a/TeslaSolarCharger/Client/Components/HiddenErrorsComponent.razor
+++ b/TeslaSolarCharger/Client/Components/HiddenErrorsComponent.razor
@@ -45,7 +45,7 @@ else
NoIcon="true"
ContentAlignment="HorizontalAlignment.Left"
ShowCloseIcon="false">
-
@(error.Headline + $" occured {error.Occurrences.Count} time(s)")
+ @(error.Headline + $"{(error.HideOccurrenceCount ? string.Empty : $" occured {error.OccurrenceCount} time(s)")}")
Hidden reason: @(error.HideReason == LoggedErrorHideReason.NotEnoughOccurrences ? "Not Enough occurrences" : "Dismissed")
diff --git a/TeslaSolarCharger/Client/Components/LoggedErrorsComponent.razor b/TeslaSolarCharger/Client/Components/LoggedErrorsComponent.razor
index c4f4aa68c..61599e9f2 100644
--- a/TeslaSolarCharger/Client/Components/LoggedErrorsComponent.razor
+++ b/TeslaSolarCharger/Client/Components/LoggedErrorsComponent.razor
@@ -44,7 +44,7 @@ else
ContentAlignment="HorizontalAlignment.Left"
ShowCloseIcon="true"
CloseIconClicked="@(_ => DismissError(error.Id))">
- @(error.Headline + $" occured {error.Occurrences.Count} time(s)")
+ @(error.Headline + $"{(error.HideOccurrenceCount ? string.Empty : $" occured {error.OccurrenceCount} time(s)")}")
@((MarkupString)error.Message)
diff --git a/TeslaSolarCharger/Server/Resources/PossibleIssues/PossibleIssues.cs b/TeslaSolarCharger/Server/Resources/PossibleIssues/PossibleIssues.cs
index d57833bac..c31d0ce6f 100644
--- a/TeslaSolarCharger/Server/Resources/PossibleIssues/PossibleIssues.cs
+++ b/TeslaSolarCharger/Server/Resources/PossibleIssues/PossibleIssues.cs
@@ -15,6 +15,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = false,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.FleetApiTokenNotRequested, new DtoIssue
@@ -23,6 +24,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = false,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.FleetApiTokenUnauthorized, new DtoIssue
@@ -47,6 +49,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = false,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.FleetApiTokenNotReceived, new DtoIssue
@@ -55,6 +58,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = false,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.FleetApiTokenExpired, new DtoIssue
@@ -63,6 +67,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = true,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.FleetApiTokenNoApiRequestsAllowed, new DtoIssue
@@ -71,6 +76,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = true,
ShowErrorAfterOccurrences = 2,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.CrashedOnStartup, new DtoIssue
@@ -79,6 +85,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = true,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.RestartNeeded, new DtoIssue
@@ -87,6 +94,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = false,
ShowErrorAfterOccurrences = 1,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
{ issueKeys.GetVehicle, new DtoIssue
@@ -191,6 +199,7 @@ public class PossibleIssues(IIssueKeys issueKeys) : IPossibleIssues
IsTelegramEnabled = true,
ShowErrorAfterOccurrences = 2,
HasPlaceHolderIssueKey = false,
+ HideOccurrenceCount = true,
}
},
};
diff --git a/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs b/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs
index 18002f0a6..147a9ee6d 100644
--- a/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs
+++ b/TeslaSolarCharger/Server/Services/ErrorHandlingService.cs
@@ -40,8 +40,9 @@ public async Task>> GetActiveLoggedErrors()
var mappingConfiguration = mapperConfigurationFactory.Create(cfg =>
{
cfg.CreateMap()
- .ForMember(d => d.Occurrences, opt => opt.MapFrom(s => new List() { s.StartTimeStamp }.Concat(s.FurtherOccurrences)))
+ .ForMember(d => d.OccurrenceCount, opt => opt.MapFrom(s => s.FurtherOccurrences.Count() + 1))
.ForMember(d => d.Severity, opt => opt.MapFrom(s => possibleIssues.GetIssueByKey(s.IssueKey).IssueSeverity))
+ .ForMember(d => d.HideOccurrenceCount, opt => opt.MapFrom(s => possibleIssues.GetIssueByKey(s.IssueKey).HideOccurrenceCount))
;
});
var mapper = mappingConfiguration.CreateMapper();
@@ -50,7 +51,7 @@ public async Task>> GetActiveLoggedErrors()
.Select(e => mapper.Map(e))
.ToList();
- var removedErrorCount = errors.RemoveAll(e => e.Occurrences.Count < possibleIssues.GetIssueByKey(e.IssueKey).ShowErrorAfterOccurrences);
+ var removedErrorCount = errors.RemoveAll(e => e.OccurrenceCount < possibleIssues.GetIssueByKey(e.IssueKey).ShowErrorAfterOccurrences);
logger.LogDebug("{removedErrorsCount} errors removed as did not reach minimum error count", removedErrorCount);
return Fin>.Succ(errors);
},
@@ -71,8 +72,9 @@ public async Task>> GetHiddenErrors()
var mappingConfiguration = mapperConfigurationFactory.Create(cfg =>
{
cfg.CreateMap()
- .ForMember(d => d.Occurrences, opt => opt.MapFrom(s => new List() { s.StartTimeStamp }.Concat(s.FurtherOccurrences)))
+ .ForMember(d => d.OccurrenceCount, opt => opt.MapFrom(s => s.FurtherOccurrences.Count() + 1))
.ForMember(d => d.Severity, opt => opt.MapFrom(s => possibleIssues.GetIssueByKey(s.IssueKey).IssueSeverity))
+ .ForMember(d => d.HideOccurrenceCount, opt => opt.MapFrom(s => possibleIssues.GetIssueByKey(s.IssueKey).HideOccurrenceCount))
;
});
var mapper2 = mappingConfiguration.CreateMapper();
diff --git a/TeslaSolarCharger/Shared/Dtos/DtoIssue.cs b/TeslaSolarCharger/Shared/Dtos/DtoIssue.cs
index 20a851245..1c5f214f2 100644
--- a/TeslaSolarCharger/Shared/Dtos/DtoIssue.cs
+++ b/TeslaSolarCharger/Shared/Dtos/DtoIssue.cs
@@ -11,4 +11,5 @@ public class DtoIssue
/// If true the issue Starts with the specified issue key and can have multiple variations separated from the main issue key by _
///
public bool HasPlaceHolderIssueKey { get; set; }
+ public bool HideOccurrenceCount { get; set; }
}
diff --git a/TeslaSolarCharger/Shared/Dtos/LoggedError/DtoLoggedError.cs b/TeslaSolarCharger/Shared/Dtos/LoggedError/DtoLoggedError.cs
index 908a6b04b..bb838029c 100644
--- a/TeslaSolarCharger/Shared/Dtos/LoggedError/DtoLoggedError.cs
+++ b/TeslaSolarCharger/Shared/Dtos/LoggedError/DtoLoggedError.cs
@@ -8,7 +8,8 @@ public class DtoLoggedError
public IssueSeverity Severity { get; set; }
public string Headline { get; set; }
public string IssueKey { get; set; }
- public List Occurrences { get; set; } = new();
+ public int OccurrenceCount { get; set; }
public string? Vin { get; set; }
public string Message { get; set; }
+ public bool HideOccurrenceCount { get; set; }
}