Update EventOccurrenceParser to process all events when no school level is set
This commit modifies the EventOccurrenceParser to ensure that when no school level is specified, all events, including high school (HS) events, are processed without filtering. The logic for skipping events based on school level has been simplified, enhancing clarity and maintainability. Corresponding unit tests have been updated to reflect this change, ensuring that HS events are handled appropriately and not incorrectly skipped when no school level is designated.
This commit is contained in:
@@ -291,7 +291,7 @@ public class EventOccurrenceParser
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a section should be skipped based on chapter's school level setting.
|
||||
/// Handles backward compatibility (null school level = skip HS).
|
||||
/// If no school level is set, all events are processed (no filtering).
|
||||
/// </summary>
|
||||
/// <param name="sectionSchoolLevel">The school level of the section (null if no school level designation).</param>
|
||||
/// <param name="normalizedLine">The normalized line content for tracking skipped headers.</param>
|
||||
@@ -302,28 +302,20 @@ public class EventOccurrenceParser
|
||||
if (!sectionSchoolLevel.HasValue)
|
||||
return false; // Events without school level are never skipped
|
||||
|
||||
if (_schoolLevel.HasValue)
|
||||
// If no school level is set, process all events (no filtering)
|
||||
if (!_schoolLevel.HasValue)
|
||||
return false;
|
||||
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && sectionSchoolLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && sectionSchoolLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && sectionSchoolLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
result.SkippedMSSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
result.SkippedHSSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && sectionSchoolLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
// No school level set - backward compatibility: skip HS events
|
||||
if (sectionSchoolLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
result.SkippedMSSectionHeaders.Add(normalizedLine);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -350,6 +342,7 @@ public class EventOccurrenceParser
|
||||
|
||||
/// <summary>
|
||||
/// Checks if current occurrence should be skipped based on section level.
|
||||
/// If no school level is set, all events are processed (no filtering).
|
||||
/// </summary>
|
||||
/// <param name="currentSectionLevel">The current section level.</param>
|
||||
/// <param name="result">The parse result to update with skip counts.</param>
|
||||
@@ -359,28 +352,20 @@ public class EventOccurrenceParser
|
||||
if (!currentSectionLevel.HasValue)
|
||||
return false; // Events without school level are never skipped
|
||||
|
||||
if (_schoolLevel.HasValue)
|
||||
// If no school level is set, process all events (no filtering)
|
||||
if (!_schoolLevel.HasValue)
|
||||
return false;
|
||||
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && currentSectionLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
// School level is set - filter based on it
|
||||
if (_schoolLevel.Value == SchoolLevel.MiddleSchool && currentSectionLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSEventCount++;
|
||||
return true;
|
||||
}
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && currentSectionLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
result.SkippedMSEventCount++;
|
||||
return true;
|
||||
}
|
||||
result.SkippedHSEventCount++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (_schoolLevel.Value == SchoolLevel.HighSchool && currentSectionLevel.Value == SchoolLevel.MiddleSchool)
|
||||
{
|
||||
// If no school level is set, skip HS sections (backward compatibility)
|
||||
if (currentSectionLevel.Value == SchoolLevel.HighSchool)
|
||||
{
|
||||
result.SkippedHSEventCount++;
|
||||
return true;
|
||||
}
|
||||
result.SkippedMSEventCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user