Skip to content

Commit

Permalink
The result_in_db field is no longer needed and its removal prevents u…
Browse files Browse the repository at this point in the history
…nnecessary searches
  • Loading branch information
carlosribas committed Mar 19, 2024
1 parent 95a5fb7 commit 13f8c27
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
11 changes: 0 additions & 11 deletions ansible/postgres_new_release.yml

This file was deleted.

12 changes: 5 additions & 7 deletions sequence_search/db/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ async def sequence_exists(engine, query):
try:
async with engine.acquire() as connection:
try:
sql_query = sa.select([Job.c.id]).select_from(Job).where(
(Job.c.query == query) & Job.c.result_in_db
)
sql_query = sa.select([Job.c.id]).select_from(Job).where((Job.c.query == query))
job_list = []
async for row in await connection.execute(sql_query):
job_list.append(row[0])
Expand Down Expand Up @@ -151,10 +149,10 @@ async def set_job_status(engine, job_id, status, hits=None):
try:
async with engine.acquire() as connection:
try:
query = sa.text('''UPDATE jobs SET status = :status, finished = :finished, hits = :hits,
result_in_db = :result_in_db WHERE id = :job_id''')
await connection.execute(query, job_id=job_id, status=status, finished=finished, hits=hits,
result_in_db=True)
query = sa.text('''
UPDATE jobs SET status = :status, finished = :finished, hits = :hits WHERE id = :job_id
''')
await connection.execute(query, job_id=job_id, status=status, finished=finished, hits=hits)
except Exception as e:
raise SQLError("Failed to save job to the database about failed job, job_id = %s, "
"status = %s" % (job_id, status)) from e
Expand Down
2 changes: 0 additions & 2 deletions sequence_search/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class CONSUMER_STATUS_CHOICES(object):
sa.Column('ordering', sa.Text, nullable=True),
sa.Column('submitted', sa.DateTime),
sa.Column('finished', sa.DateTime, nullable=True),
sa.Column('result_in_db', sa.Boolean),
sa.Column('hits', sa.Integer, nullable=True),
sa.Column('status', sa.String(255)), # choices=JOB_STATUS_CHOICES
sa.Column('r2dt_id', sa.String(255)),
Expand Down Expand Up @@ -211,7 +210,6 @@ async def migrate(ENVIRONMENT):
ordering TEXT,
submitted TIMESTAMP,
finished TIMESTAMP,
result_in_db BOOLEAN,
hits INTEGER,
status VARCHAR(255),
r2dt_id VARCHAR(255),
Expand Down
2 changes: 0 additions & 2 deletions sequence_search/db/tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ async def setUpAsync(self):
query='AACAGCATGAGTGCGCTGGATGCTG',
description='CATE_ECOLI',
submitted=datetime.datetime.now(),
result_in_db=True,
status=JOB_STATUS_CHOICES.success
)
)
Expand Down Expand Up @@ -184,7 +183,6 @@ async def setUpAsync(self):
query='AACAGCATGAGTGCGCTGGATGCTG',
description='CATE_ECOLI',
submitted=datetime.datetime.now(),
result_in_db=True,
status=JOB_STATUS_CHOICES.success
)
)
Expand Down

0 comments on commit 13f8c27

Please sign in to comment.