Enhance event definitions and parsing logic for new event types
Added new event definitions for "Meet the Candidates", "Chapter Officer Meeting", "Voting Delegate Meeting", and "Social Gathering". Updated the EventOccurrenceParser to handle these new event types and modified related services and views to accommodate the changes. Improved test coverage for the new event definitions and ensured proper parsing and display in the calendar components.
This commit is contained in:
@@ -52,33 +52,31 @@ public class EventOccurrenceParser
|
||||
currentEventDefinition = evt;
|
||||
continue;
|
||||
}
|
||||
if (line == "General Schedule")
|
||||
if (line == "General Schedule" || line == "General Session")
|
||||
{
|
||||
currentEventDefinition = EventDefinition.GeneralSchedule;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line == "Voting Delegates")
|
||||
{
|
||||
currentEventDefinition = EventDefinition.VotingDelegates;
|
||||
continue;
|
||||
}
|
||||
|
||||
// "Voting Delegates" section header is no longer used - occurrences are categorized by name pattern
|
||||
// Continue without setting currentEventDefinition for this section
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentEventDefinition == null)
|
||||
continue;
|
||||
|
||||
var occurrenceName = match.Groups["Name"].Captures[0].Value;
|
||||
var month = match.Groups["Month"].Captures[0].Value;
|
||||
var dayOfMonth = match.Groups["DayOfMonth"].Captures[0].Value;
|
||||
var timeAndLocation = match.Groups["TimeAndLocation"].Captures[0].Value;
|
||||
|
||||
|
||||
occurrenceName = Regex.Replace(occurrenceName,
|
||||
@"(?<Weekday>Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),\s?$", "").Trim();
|
||||
|
||||
// Determine event definition based on occurrence name pattern or current section
|
||||
EventDefinition? eventDefinition = DetermineEventDefinition(occurrenceName, currentEventDefinition);
|
||||
|
||||
// Skip if we can't determine the event definition
|
||||
if (eventDefinition == null)
|
||||
continue;
|
||||
|
||||
timeAndLocation = SanitizeInput(timeAndLocation);
|
||||
var timeAndLocationMatch = _timeLocationRegex.Match(timeAndLocation);
|
||||
@@ -103,14 +101,41 @@ public class EventOccurrenceParser
|
||||
Location = location
|
||||
};
|
||||
|
||||
if (!occurrences.ContainsKey(currentEventDefinition))
|
||||
occurrences.Add(currentEventDefinition, []);
|
||||
occurrences[currentEventDefinition].Add(eventOccurrence);
|
||||
if (!occurrences.ContainsKey(eventDefinition))
|
||||
occurrences.Add(eventDefinition, []);
|
||||
occurrences[eventDefinition].Add(eventOccurrence);
|
||||
}
|
||||
|
||||
return occurrences;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the EventDefinition for an occurrence based on its name pattern or current section context.
|
||||
/// </summary>
|
||||
private EventDefinition? DetermineEventDefinition(string occurrenceName, EventDefinition? currentEventDefinition)
|
||||
{
|
||||
// Check for special event name patterns first (regardless of current section)
|
||||
if (occurrenceName.Contains("Meet the Candidates Session", StringComparison.OrdinalIgnoreCase))
|
||||
return EventDefinition.MeetTheCandidates;
|
||||
|
||||
if (occurrenceName.Contains("Chapter Officer Meeting", StringComparison.OrdinalIgnoreCase))
|
||||
return EventDefinition.ChapterOfficerMeeting;
|
||||
|
||||
if (occurrenceName.Contains("Voting Delegate Meeting", StringComparison.OrdinalIgnoreCase))
|
||||
return EventDefinition.VotingDelegateMeeting;
|
||||
|
||||
// If we're in a General Schedule/Session section and no pattern matched, use GeneralSchedule
|
||||
if (currentEventDefinition == EventDefinition.GeneralSchedule)
|
||||
return EventDefinition.GeneralSchedule;
|
||||
|
||||
// If we have a current event definition from section header (e.g., regular events), use it
|
||||
if (currentEventDefinition != null)
|
||||
return currentEventDefinition;
|
||||
|
||||
// Cannot determine event definition
|
||||
return null;
|
||||
}
|
||||
|
||||
private string SanitizeInput(string input)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user