Skip to content

Commit

Permalink
Update auto_archive_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
r350178982 committed Mar 3, 2023
1 parent c2160f4 commit 947985c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dtable_events/big_data/auto_archive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from dtable_events.utils.sql_generator import BaseSQLGenerator

logger = logging.getLogger(__name__)

PER_DAY = 'per_day'
PER_WEEK = 'per_week'
PER_MONTH = 'per_month'

VALID_RUN_CONDITIONS = [
PER_DAY,
PER_WEEK,
PER_MONTH
]

def update_last_run_time(task_id, db_session):

cmd = "UPDATE dtable_auto_archive_task SET last_run_time=:new_time WHERE id=:task_id"
Expand All @@ -23,15 +34,15 @@ def meet_condition(run_condition, details):
cur_hour = int(cur_datetime.hour)
cur_week_day = cur_datetime.isoweekday()
cur_month_day = cur_datetime.day
if run_condition == 'per_day':
if run_condition == PER_DAY:
run_hour = details.get('run_hour', None)
try:
if int(run_hour) == cur_hour:
return True
except:
return False

if run_condition == 'per_week':
if run_condition == PER_WEEK:
run_week_day = details.get('run_week_day', None)
run_week_hour = details.get('run_week_hour', None)
try:
Expand All @@ -40,7 +51,7 @@ def meet_condition(run_condition, details):
except:
return False

if run_condition == 'per_month':
if run_condition == PER_MONTH:
run_month_day = details.get('run_month_day', None)
run_month_hour = details.get('run_month_hour', None)
try:
Expand Down

0 comments on commit 947985c

Please sign in to comment.