Compare commits
No commits in common. "964bbb116227a1e4bcb60f0a0a469ebd8557bb6e" and "4c651198f34777f930b9f363998cb31a5717f20a" have entirely different histories.
964bbb1162
...
4c651198f3
|
@ -97,8 +97,8 @@ def find_events_during_stay(
|
||||||
async def time_function(
|
async def time_function(
|
||||||
name: str,
|
name: str,
|
||||||
func: typing.Callable[..., typing.Coroutine[typing.Any, typing.Any, typing.Any]],
|
func: typing.Callable[..., typing.Coroutine[typing.Any, typing.Any, typing.Any]],
|
||||||
*args: typing.Any,
|
*args,
|
||||||
**kwargs: typing.Any,
|
**kwargs,
|
||||||
) -> tuple[str, typing.Any, float, Exception | None]:
|
) -> tuple[str, typing.Any, float, Exception | None]:
|
||||||
"""Time the execution of an asynchronous function."""
|
"""Time the execution of an asynchronous function."""
|
||||||
start_time, result, exception = time(), None, None
|
start_time, result, exception = time(), None, None
|
||||||
|
@ -110,24 +110,6 @@ async def time_function(
|
||||||
return name, result, end_time - start_time, exception
|
return name, result, end_time - start_time, exception
|
||||||
|
|
||||||
|
|
||||||
def hide_markets_while_away(
|
|
||||||
events: list[Event], accommodation_events: list[Event]
|
|
||||||
) -> None:
|
|
||||||
"""Hide markets that happen while away."""
|
|
||||||
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]
|
|
||||||
|
|
||||||
overlapping_markets = find_events_during_stay(
|
|
||||||
accommodation_events + going, optional
|
|
||||||
)
|
|
||||||
for market in overlapping_markets:
|
|
||||||
events.remove(market)
|
|
||||||
|
|
||||||
|
|
||||||
async def get_data(
|
async def get_data(
|
||||||
now: datetime, config: flask.config.Config
|
now: datetime, config: flask.config.Config
|
||||||
) -> typing.Mapping[str, str | object]:
|
) -> typing.Mapping[str, str | object]:
|
||||||
|
@ -228,8 +210,19 @@ async def get_data(
|
||||||
events += hn.whoishiring(last_year, next_year)
|
events += hn.whoishiring(last_year, next_year)
|
||||||
events += carnival.rio_carnival_events(last_year, next_year)
|
events += carnival.rio_carnival_events(last_year, next_year)
|
||||||
|
|
||||||
if config["HIDE_MARKETS_WHILE_AWAY"]:
|
# hide markets that happen while away
|
||||||
hide_markets_while_away(events, accommodation_events)
|
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]
|
||||||
|
|
||||||
|
overlapping_markets = find_events_during_stay(
|
||||||
|
accommodation_events + going, optional
|
||||||
|
)
|
||||||
|
for market in overlapping_markets:
|
||||||
|
events.remove(market)
|
||||||
|
|
||||||
for launch in rockets:
|
for launch in rockets:
|
||||||
dt = None
|
dt = None
|
||||||
|
|
Loading…
Reference in a new issue