Update EventOccurrence parsing to use EventOccurrenceParseGroup for improved data structure
This commit refactors the EventOccurrence parsing logic to utilize the EventOccurrenceParseGroup class, enhancing the organization of parsed occurrences by grouping them based on event definitions and optional section levels. The changes include updates to the EventOccurrenceParseResult, EventOccurrenceParser, and EventOccurrenceParserService to accommodate the new grouping structure. Additionally, tests are modified to reflect these changes, ensuring that the parsing functionality remains intact and accurate. This refactor improves data handling and aligns with the overall architecture of the application.
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
@if (_parseResult.IsSuccess && _parseResult.TotalParsed > 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Dense="true">
|
||||
Successfully parsed @_parseResult.TotalParsed occurrence(s) from @_parseResult.Occurrences.Count event definition(s)
|
||||
Successfully parsed @_parseResult.TotalParsed occurrence(s) in @_parseResult.Occurrences.Count group(s)
|
||||
@if (_parseResult.SkippedEventCount > 0)
|
||||
{
|
||||
<text> (Skipped @_parseResult.SkippedEventCount event occurrence(s) from other school level)</text>
|
||||
@@ -201,9 +201,11 @@
|
||||
{
|
||||
<MudText Typo="Typo.h6" Class="mt-4 mb-2">Occurrences by Event:</MudText>
|
||||
<MudExpansionPanels Elevation="0">
|
||||
@foreach (var kvp in _parseResult.Occurrences.OrderBy(x => GetEventName(x.Key)))
|
||||
@foreach (var kvp in _parseResult.Occurrences
|
||||
.OrderBy(x => GetEventName(x.Key.EventDefinition))
|
||||
.ThenBy(x => x.Key.SectionSchoolLevel switch { SchoolLevel.MiddleSchool => 0, SchoolLevel.HighSchool => 1, _ => 2 }))
|
||||
{
|
||||
<MudExpansionPanel Text="@GetEventName(kvp.Key)">
|
||||
<MudExpansionPanel Text="@GetOccurrenceGroupTitle(kvp.Key)">
|
||||
<MudTable Items="@kvp.Value" Dense="true" Hover="true" Striped="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Name</MudTh>
|
||||
@@ -395,6 +397,17 @@
|
||||
return eventDefinition.Name;
|
||||
}
|
||||
|
||||
private string GetOccurrenceGroupTitle(EventOccurrenceParseGroup group)
|
||||
{
|
||||
var title = GetEventName(group.EventDefinition);
|
||||
return group.SectionSchoolLevel switch
|
||||
{
|
||||
SchoolLevel.MiddleSchool => $"{title} (MS)",
|
||||
SchoolLevel.HighSchool => $"{title} (HS)",
|
||||
_ => title
|
||||
};
|
||||
}
|
||||
|
||||
private Color GetIssueTypeColor(ParsingIssueType issueType)
|
||||
{
|
||||
return issueType switch
|
||||
|
||||
Reference in New Issue
Block a user