Skip to content

Commit

Permalink
Make the logic around schedule['until'] easier to read (#3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr authored and ranbena committed Feb 3, 2019
1 parent 3992bcd commit 933dd75
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
import csv
import datetime
import calendar
import functools
import hashlib
import itertools
import logging
import time
import pytz
from functools import reduce

import xlsxwriter
from six import python_2_unicode_compatible, text_type
Expand Down Expand Up @@ -562,13 +558,15 @@ def outdated_queries(cls):
scheduled_queries_executions.refresh()

for query in queries:
schedule_until = pytz.utc.localize(datetime.datetime.strptime(
query.schedule['until'], '%Y-%m-%d')) if query.schedule['until'] else None
if (query.schedule['interval'] == None or (
schedule_until != None and (
schedule_until <= now))):
if query.schedule['interval'] is None:
continue

if query.schedule['until'] is not None:
schedule_until = pytz.utc.localize(datetime.datetime.strptime(query.schedule['until'], '%Y-%m-%d'))

if schedule_until <= now:
continue

if query.latest_query_data:
retrieved_at = query.latest_query_data.retrieved_at
else:
Expand Down

0 comments on commit 933dd75

Please sign in to comment.