Commit 042b7af4 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Pass fp_db to lookup_submission_status

parent bbd57eb0
Pipeline #20575 passed with stages
in 7 minutes and 6 seconds
......@@ -649,7 +649,7 @@ class SubmissionStatusHandler(APIHandler):
# type: (APIHandlerParams) -> Dict[str, Any]
assert isinstance(params, SubmissionStatusHandlerParams)
response = {'submissions': [{'id': id, 'status': 'pending'} for id in params.ids]}
tracks = lookup_submission_status(self.ctx.db.get_ingest_db(read_only=True), params.ids)
tracks = lookup_submission_status(self.ctx.db.get_ingest_db(read_only=True), self.ctx.db.get_fingerprint_db(read_only=True), params.ids)
for submission in response['submissions']:
id = submission['id']
track_gid = tracks.get(id)
......@@ -785,6 +785,7 @@ class SubmitHandler(APIHandler):
self.ctx.redis.publish('channel.submissions', json.dumps(list(ids)))
ingest_db = self.ctx.db.get_ingest_db()
fingerprint_db = self.ctx.db.get_fingerprint_db()
clients_waiting_key = 'submission.waiting'
clients_waiting = self.ctx.redis.incr(clients_waiting_key) - 1
......@@ -797,7 +798,7 @@ class SubmitHandler(APIHandler):
logger.debug('waiting %f seconds', remaining)
time.sleep(0.5) # XXX replace with LISTEN/NOTIFY
remaining -= 0.5
tracks = lookup_submission_status(ingest_db, ids)
tracks = lookup_submission_status(ingest_db, fingerprint_db, ids)
if not tracks:
continue
for submission in response['submissions']:
......
......@@ -183,8 +183,8 @@ def import_queued_submissions(ingest_db, app_db, fingerprint_db, index, limit=10
return count
def lookup_submission_status(ingest_db, ids):
# type: (IngestDB, Iterable[int]) -> Dict[int, str]
def lookup_submission_status(ingest_db, fingerprint_db, ids):
# type: (IngestDB, FingerprintDB, Iterable[int]) -> Dict[int, str]
if not ids:
return {}
......@@ -201,7 +201,7 @@ def lookup_submission_status(ingest_db, ids):
query = sql.select([schema.fingerprint.c.id, schema.track.c.gid], from_obj=source).\
where(schema.fingerprint.c.id.in_(fingerprint_ids))
track_gids = {} # type: Dict[int, str]
for fingerprint_id, track_gid in ingest_db.execute(query):
for fingerprint_id, track_gid in fingerprint_db.execute(query):
track_gids[fingerprint_id] = track_gid
if not track_gids:
......
Markdown is supported
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