From f8dfafcecfbf30084c23a40db9662ecf37df7c7e Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Fri, 10 Mar 2023 14:04:05 +0000 Subject: [PATCH] Don't try to fetch votes from future sessions In ea5ba20fba95cb6ded70e7c704f6c102857e3904, I revised the votes task to accept just a congress number and it would come up with the session numbers. But this led to unneecssary warnings about not being able to get votes for a session that hasn't yet started. --- congress/tasks/votes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/congress/tasks/votes.py b/congress/tasks/votes.py index d590c15..5beffd3 100644 --- a/congress/tasks/votes.py +++ b/congress/tasks/votes.py @@ -29,9 +29,12 @@ def run(options): # Fetch for one session given with the congress and session options. sessions = [(options.get('congress'), options.get('session'))] else: - # Fetch for both sessions of a Congress. - sessions = [(options.get('congress'), str(utils.get_congress_first_year(options.get('congress')))), - (options.get('congress'), str(utils.get_congress_first_year(options.get('congress')) + 1))] + # Fetch for both sessions of a Congress except sessions that are in the future. + sessions = [] + first_session_year = utils.get_congress_first_year(options.get('congress')) + for y in (first_session_year, first_session_year + 1): + if y > datetime.datetime.now().year: continue # this session hasn't started yet + sessions.append( (options.get('congress'), str(y)) ) elif options.get('sessions', None): # Fetch for multiple sessions, e.g. sessions=117.2021,117.2022 sessions = [session.split('.') for session in options.get('sessions').split(',')]