Enhance event occurrence parsing to skip unmatched high school section headers

This commit introduces a new property to track skipped high school section headers in the EventOccurrenceParseResult and EventOccurrenceParserResult classes. The EventOccurrenceParser has been updated to gracefully skip HS section headers that do not match any event definitions, improving the parsing logic. Additionally, the LocationParsingConfiguration has been removed from the EventOccurrenceParser, simplifying its constructor. Unit tests have been updated to reflect these changes and ensure correct behavior during parsing.
This commit is contained in:
2026-01-09 00:14:19 -05:00
parent f916cfad6b
commit 19e5ef0675
10 changed files with 279 additions and 372 deletions
+6 -14
View File
@@ -12,20 +12,9 @@ namespace Core.Services;
/// </summary>
public class EventOccurrenceParserService : IEventOccurrenceParserService
{
private readonly LocationParsingConfiguration? _locationConfig;
public EventOccurrenceParserService(IConfiguration? configuration = null)
{
// Load location parsing configuration from IConfiguration if provided
if (configuration != null)
{
_locationConfig = configuration.GetSection("LocationParsingSettings").Get<LocationParsingConfiguration>()
?? LocationParsingConfiguration.Default;
}
else
{
_locationConfig = LocationParsingConfiguration.Default;
}
// Configuration parameter kept for backward compatibility but not used
}
/// <inheritdoc/>
@@ -48,8 +37,8 @@ public class EventOccurrenceParserService : IEventOccurrenceParserService
File.WriteAllText(tempFile, text, Encoding.UTF8);
var fileInfo = new FileInfo(tempFile);
// Use the existing EventOccurrenceParser with location configuration
var parser = new EventOccurrenceParser(fileInfo, events, _locationConfig);
// Use the existing EventOccurrenceParser
var parser = new EventOccurrenceParser(fileInfo, events);
var parserResult = parser.Parse();
// Copy occurrences from parser result
@@ -101,6 +90,9 @@ public class EventOccurrenceParserService : IEventOccurrenceParserService
// Copy parsing issues from parser result
result.Issues.AddRange(parserResult.Issues);
// Copy skipped HS section headers from parser result
result.SkippedHSSectionHeaders.AddRange(parserResult.SkippedHSSectionHeaders);
}
finally
{