diff options
author | emkael <emkael@tlen.pl> | 2014-10-06 16:05:57 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2014-10-06 16:05:57 +0200 |
commit | 55e966eb554143cee7fe81ee574fca22a6bb25ff (patch) | |
tree | 6ded9de9e90cb196ae54a5ce476eaf21612c97ae /elo.py | |
parent | 7127fd85771045a62030dc9cef840a347b639308 (diff) |
* output sanitation if rankings are not available
Diffstat (limited to 'elo.py')
-rwxr-xr-x | elo.py | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -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() |