Verified Commit 249fa6d6 authored by Peter Stanko's avatar Peter Stanko
Browse files

Fixes in async processing

parent e0f34514
Pipeline #31351 passed with stage
in 7 minutes and 18 seconds
......@@ -25,6 +25,8 @@ class AsyncManager:
def _proc_expired(self, submission: Submission, limit, param='scheduled_for'):
req_time = getattr(submission, param)
if not req_time:
return False
schedule_time = time.normalize_time(req_time)
curr = time.current_time()
exp_time = limit + schedule_time
......
......@@ -114,15 +114,14 @@ def user_by_uco(uco: int) -> BaseQuery:
return User.query.filter(User.uco == uco)
def submissions_to_be_archived() -> BaseQuery:
def submissions_finished() -> BaseQuery:
"""Returns the collection of finished submissions that are finished
and the project is archived.
Returns(BaseQuery): Query to get the result
"""
return Submission.query.join(Submission.project).filter(
Submission.state == SubmissionState.FINISHED &
Project.is_archived)
Submission.state == SubmissionState.FINISHED)
def cancelled_submissions_for_deletion(time_period: datetime.timedelta) -> BaseQuery:
......@@ -138,7 +137,7 @@ def cancelled_submissions_for_deletion(time_period: datetime.timedelta) -> BaseQ
"""
delete_from = datetime.datetime.now() - time_period
return Submission.query.filter(
Submission.state.in_(SubmissionState.CANCELLED, SubmissionState.ABORTED) &
Submission.state.in_([SubmissionState.CANCELLED, SubmissionState.ABORTED]) &
Submission.created_at < delete_from)
......
......@@ -243,10 +243,11 @@ class SubmissionsService(GeneralService):
SubmissionsService(submission).delete()
def archive_submissions(self):
query_filter = queries.submissions_to_be_archived()
query_filter = queries.submissions_finished().all()
filtered = [submission for submission in query_filter if submission.project.is_archived]
log.info(f"[ARCH] Archiving submissions "
f"({query_filter}): {query_filter.all()}")
for submission in query_filter.all():
f": {[s.log_name for s in filtered]}")
for submission in filtered:
SubmissionsService(submission).archive()
def archive(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment