Refactor event occurrence parsing to unify section header handling and event count tracking
This commit updates the EventOccurrenceParseResult and EventOccurrenceParserResult classes to consolidate the handling of skipped section headers and event counts into a single set of properties. The previous separate lists and counts for middle school and high school sections have been replaced with a unified approach, improving clarity and maintainability. Additionally, the EventOccurrenceParserService has been modified to reflect these changes, ensuring consistent behavior across the application. This refactor enhances the overall structure of the event parsing logic.
This commit is contained in:
@@ -31,26 +31,17 @@ public class EventOccurrenceParseResult
|
||||
public List<ParsingIssue> Issues { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of high school (HS) section headers that were encountered but skipped
|
||||
/// List of section headers that were encountered but skipped
|
||||
/// because they don't match the chapter's school level setting.
|
||||
/// Headers may contain " - MS" or " - HS" to indicate school level.
|
||||
/// </summary>
|
||||
public List<string> SkippedHSSectionHeaders { get; set; } = new();
|
||||
public List<string> SkippedSectionHeaders { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of middle school (MS) section headers that were encountered but skipped
|
||||
/// because they don't match the chapter's school level setting.
|
||||
/// Number of event occurrences that were skipped due to school level filtering.
|
||||
/// This includes both MS and HS events that don't match the chapter's school level setting.
|
||||
/// </summary>
|
||||
public List<string> SkippedMSSectionHeaders { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Number of Middle School (MS) event occurrences that were skipped due to school level filtering.
|
||||
/// </summary>
|
||||
public int SkippedMSEventCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of High School (HS) event occurrences that were skipped due to school level filtering.
|
||||
/// </summary>
|
||||
public int SkippedHSEventCount { get; set; }
|
||||
public int SkippedEventCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Footnotes captured for each event definition. Footnotes are lines that start with "*" or are parenthetical notes.
|
||||
|
||||
@@ -14,10 +14,8 @@ public class EventOccurrenceParserResult
|
||||
{
|
||||
public IDictionary<EventDefinition, List<Entities.EventOccurrence>> Occurrences { get; set; } = new Dictionary<EventDefinition, List<Entities.EventOccurrence>>();
|
||||
public List<ParsingIssue> Issues { get; set; } = new();
|
||||
public List<string> SkippedHSSectionHeaders { get; set; } = new();
|
||||
public List<string> SkippedMSSectionHeaders { get; set; } = new();
|
||||
public int SkippedMSEventCount { get; set; }
|
||||
public int SkippedHSEventCount { get; set; }
|
||||
public List<string> SkippedSectionHeaders { get; set; } = new();
|
||||
public int SkippedEventCount { get; set; }
|
||||
/// <summary>
|
||||
/// Footnotes captured for each event definition. Footnotes are lines that start with "*" or are parenthetical notes.
|
||||
/// Multiple footnotes are concatenated into a single string.
|
||||
@@ -329,12 +327,12 @@ public class EventOccurrenceParser
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && sectionSchoolLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSSectionHeaders.Add(normalizedLine);
|
||||
result.SkippedSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && sectionSchoolLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
result.SkippedMSSectionHeaders.Add(normalizedLine);
|
||||
result.SkippedSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -379,12 +377,12 @@ public class EventOccurrenceParser
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && currentSectionLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSEventCount++;
|
||||
result.SkippedEventCount++;
|
||||
return true;
|
||||
}
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && currentSectionLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
result.SkippedMSEventCount++;
|
||||
result.SkippedEventCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,10 +110,8 @@ public class EventOccurrenceParserService : IEventOccurrenceParserService
|
||||
result.Issues.AddRange(parserResult.Issues);
|
||||
|
||||
// Copy skipped section headers from parser result
|
||||
result.SkippedHSSectionHeaders.AddRange(parserResult.SkippedHSSectionHeaders);
|
||||
result.SkippedMSSectionHeaders.AddRange(parserResult.SkippedMSSectionHeaders);
|
||||
result.SkippedMSEventCount = parserResult.SkippedMSEventCount;
|
||||
result.SkippedHSEventCount = parserResult.SkippedHSEventCount;
|
||||
result.SkippedSectionHeaders.AddRange(parserResult.SkippedSectionHeaders);
|
||||
result.SkippedEventCount = parserResult.SkippedEventCount;
|
||||
|
||||
// Copy footnotes from parser result
|
||||
foreach (var kvp in parserResult.Footnotes)
|
||||
@@ -121,14 +119,10 @@ public class EventOccurrenceParserService : IEventOccurrenceParserService
|
||||
result.Footnotes[kvp.Key] = kvp.Value;
|
||||
}
|
||||
|
||||
// Add informational messages about skipped events
|
||||
if (parserResult.SkippedMSEventCount > 0)
|
||||
// Add informational message about skipped events
|
||||
if (parserResult.SkippedEventCount > 0)
|
||||
{
|
||||
result.Warnings.Add($"Skipped {parserResult.SkippedMSEventCount} Middle School (MS) event occurrence(s) based on school level setting");
|
||||
}
|
||||
if (parserResult.SkippedHSEventCount > 0)
|
||||
{
|
||||
result.Warnings.Add($"Skipped {parserResult.SkippedHSEventCount} High School (HS) event occurrence(s) based on school level setting");
|
||||
result.Warnings.Add($"Skipped {parserResult.SkippedEventCount} event occurrence(s) from other school level based on school level setting");
|
||||
}
|
||||
|
||||
// Validate locations and add warnings for problematic ones
|
||||
|
||||
Reference in New Issue
Block a user