Skip to content

Commit

Permalink
Refactor result expiration time to config
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmac committed Sep 7, 2023
1 parent cc846d6 commit e49a1c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
SLIVKA_URL = os.environ.get('SLIVKA_URL', 'http://localhost:8000/')
EXPIRATION_DAYS = float(os.environ.get('APP_EXPIRATION_DAYS', 7))
4 changes: 2 additions & 2 deletions submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}.")
Expand Down

0 comments on commit e49a1c1

Please sign in to comment.