Hide LHG run club when on a trip

Closes: #95
This commit is contained in:
Edward Betts 2024-01-08 15:20:48 +00:00
parent 3d16e30aa8
commit cd0ffb3390

View file

@ -261,7 +261,7 @@ def read_events_yaml(data_dir: str, start: date, end: date) -> list[Event]:
return events return events
def find_markets_during_stay( def find_events_during_stay(
accommodation_events: list[Event], markets: list[Event] accommodation_events: list[Event], markets: list[Event]
) -> list[Event]: ) -> list[Event]:
"""Market events that happen during accommodation stays.""" """Market events that happen during accommodation stays."""
@ -451,11 +451,15 @@ async def get_data(
events += domains.renewal_dates(my_data) events += domains.renewal_dates(my_data)
# hide markets that happen while away # hide markets that happen while away
markets = [e for e in events if e.name == "market"] optional = [
e
for e in events
if e.name == "market" or (e.title and "LHG Run Club" in e.title)
]
going = [e for e in events if e.going] going = [e for e in events if e.going]
overlapping_markets = find_markets_during_stay( overlapping_markets = find_events_during_stay(
accommodation_events + going, markets accommodation_events + going, optional
) )
for market in overlapping_markets: for market in overlapping_markets:
events.remove(market) events.remove(market)