Fix bug increase caching.

This commit is contained in:
Casper 2019-04-06 21:12:16 +02:00
parent 53e5b99ca2
commit 63775b7887
No known key found for this signature in database
GPG Key ID: 289CA03790535054
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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():
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: