Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big data auto archiving #401

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update auto_archive_utils.py
  • Loading branch information
r350178982 committed Aug 28, 2023
commit 287b39bba94dc106fb55162aaa430b1516965b37
17 changes: 14 additions & 3 deletions dtable_events/big_data/auto_archive_utils.py
Original file line number Diff line number Diff line change
@@ -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"
@@ -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:
@@ -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: