summaryrefslogtreecommitdiff
path: root/elo.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-10-06 16:05:57 +0200
committeremkael <emkael@tlen.pl>2014-10-06 16:05:57 +0200
commit55e966eb554143cee7fe81ee574fca22a6bb25ff (patch)
tree6ded9de9e90cb196ae54a5ce476eaf21612c97ae /elo.py
parent7127fd85771045a62030dc9cef840a347b639308 (diff)
* output sanitation if rankings are not available
Diffstat (limited to 'elo.py')
-rwxr-xr-xelo.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/elo.py b/elo.py
index 426efab..8729652 100755
--- a/elo.py
+++ b/elo.py
@@ -71,19 +71,20 @@ if date is None:
date = datetime.date.today()
date += one_day
-print 'Rankings for %s' % date
-
one_year = dateutil.relativedelta.relativedelta(years=1)
-
rankings = session.query(Ranking).filter(Ranking.rank_date > (date - one_year)).filter(Ranking.rank_date <= date).all()
-drivers = {}
-for ranking in rankings:
- if not drivers.has_key(ranking.driver):
- drivers[ranking.driver] = ranking.driver.get_ranking(date)
+if len(rankings):
+ print 'Rankings for %s' % date
-for rank in sorted(drivers.values(), key=lambda rank: rank.ranking, reverse=True):
- print rank
+ drivers = {}
+ for ranking in rankings:
+ if not drivers.has_key(ranking.driver):
+ drivers[ranking.driver] = ranking.driver.get_ranking(date)
-session.commit()
+ for rank in sorted(drivers.values(), key=lambda rank: rank.ranking, reverse=True):
+ print rank
+else:
+ print 'No rankings for %s' % date
+session.commit()