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 57a0a9c commit c2160f4
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions dtable_events/big_data/auto_archive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,36 @@ def set_invalid(task_id, db_session):
logger.error(e)

def meet_condition(run_condition, details):
cur_datetime = datetime.now()
cur_hour = int(cur_datetime.hour)
cur_week_day = cur_datetime.isoweekday()
cur_month_day = cur_datetime.day
if run_condition == 'per_day':
run_hour = details.get('run_hour', None)
cur_datetime = datetime.now()
cur_hour = int(cur_datetime.hour)
try:
if int(run_hour) == cur_hour:
return True
except:
return False

if run_condition == 'per_week':
run_week_day = details.get('run_week_day', None)
run_week_hour = details.get('run_week_hour', None)
try:
if (int(run_week_hour) == cur_hour) and (int(run_week_day) == cur_week_day):
return True
except:
return False

if run_condition == 'per_month':
run_month_day = details.get('run_month_day', None)
run_month_hour = details.get('run_month_hour', None)
try:
if (int(run_month_hour) == cur_hour) and (int(run_month_day) == cur_month_day):
return True
except:
return False


return False

Expand Down

0 comments on commit c2160f4

Please sign in to comment.