diff --git a/server/nightr/strategies/cars_in_traffic.py b/server/nightr/strategies/cars_in_traffic.py index 7c1ff40..dcb1deb 100644 --- a/server/nightr/strategies/cars_in_traffic.py +++ b/server/nightr/strategies/cars_in_traffic.py @@ -27,13 +27,13 @@ def cars_in_traffic(context: Context) -> Prediction: diff = day_avr - night_avr if curr_avg >= day_avr: - p.reasons.append(f"Because {curr_avg:.1f} cars are driving around Aarhus right now and {day_avr:.0f} is the expected number for daytime") + p.reasons.append(f"Because {curr_avg:.1f} cars are driving around Aarhus right now and {day_avr:.1f} is the expected number for daytime") p.probability = 0.0 elif curr_avg <= night_avr: - p.reasons.append(f"Because {curr_avg::.1f} cars are driving around Aarhus right now and {night_avr:.0f} is the expected number for nighttime") + p.reasons.append(f"Because {curr_avg:.1f} cars are driving around Aarhus right now and {night_avr:.1f} is the expected number for nighttime") p.probability = 1.0 else: - p.reasons.append(f"Because average for daytime is {day_avr} and average for nighttime is {night_avr:.0f}, but the current average is {curr_avg}") + p.reasons.append(f"Because average for daytime is {day_avr:.1f} and average for nighttime is {night_avr:.1f}, but the current average is {curr_avg:.1f}") res = 1 - curr_avg / diff p.probability = res diff --git a/server/nightr/strategies/upstairs_neighbour.py b/server/nightr/strategies/upstairs_neighbour.py index bfc45fa..25ce40f 100644 --- a/server/nightr/strategies/upstairs_neighbour.py +++ b/server/nightr/strategies/upstairs_neighbour.py @@ -1,12 +1,17 @@ import requests from bs4 import BeautifulSoup -from datetime import datetime +from datetime import datetime, timedelta from ..util import Prediction, Context +last_update = datetime.min def update(): - requests.post('https://euw.op.gg/summoner/ajax/renew.json/', data={'summonerId': 34009256}) + global last_update + now = datetime.utcnow() + if (now - timedelta(minutes=5)) > last_update: + requests.post('https://euw.op.gg/summoner/ajax/renew.json/', data={'summonerId': 34009256}) + last_update = now def check_games(context: Context) -> Prediction: