From e49a1c18fe50de1912cdc9501c4f9f11ed0d868a Mon Sep 17 00:00:00 2001 From: Stuart MacGowan Date: Thu, 7 Sep 2023 15:10:20 +0100 Subject: [PATCH] Refactor result expiration time to config --- config.py | 3 ++- submission.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 22f5e57..f81b7a0 100644 --- a/config.py +++ b/config.py @@ -11,4 +11,5 @@ DATABASE_PATH = os.path.join(BASE_DIR, 'db', 'session.sqlite') DATABASE_PATH = os.environ.get('APP_DATABASE_PATH', DATABASE_PATH) -SLIVKA_URL = os.environ.get('SLIVKA_URL', 'http://localhost:8000/') \ No newline at end of file +SLIVKA_URL = os.environ.get('SLIVKA_URL', 'http://localhost:8000/') +EXPIRATION_DAYS = float(os.environ.get('APP_EXPIRATION_DAYS', 7)) \ No newline at end of file diff --git a/submission.py b/submission.py index 393b39e..e570d08 100644 --- a/submission.py +++ b/submission.py @@ -6,7 +6,7 @@ from gevent.event import Event from slivka_client import SlivkaClient -from config import SESSIONS_FOLDER, SLIVKA_URL +from config import SESSIONS_FOLDER, SLIVKA_URL, EXPIRATION_DAYS from logger_config import setup_logging from session_db import insert_metadata, update_status @@ -65,7 +65,7 @@ def save_submission_data(self): def store_submission_metadata(self): """Insert metadata related to the submission into the database.""" - expiration_time = (self.submission_time + timedelta(days=7)).strftime('%Y-%m-%d %H:%M:%S') + expiration_time = (self.submission_time + timedelta(days=EXPIRATION_DAYS)).strftime('%Y-%m-%d %H:%M:%S') insert_metadata(self.session_id, self.fasta_filename, 'output.fasta', self.submission_time.strftime('%Y-%m-%d %H:%M:%S'), 'uploaded', expiration_time) self.metadata_available.set() # Signal that metadata is available custom_logger.info(f"Metadata inserted into database for session {self.session_id}.")