Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alexander Munch-Hansen 2019-04-07 00:06:15 +02:00
commit 1c9cdf497b

View file

@ -34,6 +34,7 @@ def australiaStrat(context : Context) -> Prediction:
t = datetime.now().astimezone(australia)
hour = t.hour
p = Prediction()
p.weight = 1.0
if hour > 22 or hour < 6:
p.probability = 0.0
@ -51,7 +52,7 @@ def tv2newsStrat(context : Context) -> Prediction:
r = requests.get('http://mpx.services.tv2.dk/api/latest')
data = r.json()
publish_dates = [(x['pubDate'])//1000 for x in data][:10]
publish_dates = [(x['pubDate'])//1000 for x in data[:5]]
delta_times = []
for i in range(len(publish_dates)):
if i == 0 : continue
@ -66,6 +67,7 @@ def tv2newsStrat(context : Context) -> Prediction:
p.weight = 0.0
else:
p.weight = 0.7
p.probability = 1.0 if avg_timestamp > 50 else 0.0
p.reasons.append('There were ' + ('few' if avg_timestamp > 50 else 'many') + ' recent articles on TV2 News')
print(avg_timestamp)
p.probability = 0.75 if avg_timestamp > 40 else 0.25
p.reasons.append('There were ' + ('few' if avg_timestamp > 40 else 'many') + ' recent articles on TV2 News')
return p