Commit bbd57eb0 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Fix multi-db lookup_submission_status

parent b30f6e68
Pipeline #20569 passed with stages
in 4 minutes and 30 seconds
......@@ -187,12 +187,30 @@ def lookup_submission_status(ingest_db, ids):
# type: (IngestDB, Iterable[int]) -> Dict[int, str]
if not ids:
return {}
source = schema.fingerprint_source.\
join(schema.fingerprint).\
join(schema.track)
query = sql.select([schema.fingerprint_source.c.submission_id, schema.track.c.gid], from_obj=source).\
query = sql.select([schema.fingerprint_source.c.submission_id, schema.fingerprint_source.c.fingerprint_id]).\
where(schema.fingerprint_source.c.submission_id.in_(ids))
fingerprint_ids = {} # type: Dict[int, int]
for submission_id, fingerprint_id in ingest_db.execute(query):
fingerprint_ids[submission_id] = fingerprint_id
if not fingerprint_ids:
return {}
source = schema.fingerprint.join(schema.track)
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):
track_gids[fingerprint_id] = track_gid
if not track_gids:
return {}
results = {} # type: Dict[int, str]
for id, track_gid in ingest_db.execute(query):
results[id] = track_gid
for submission_id in ids:
fingerprint_id = fingerprint_ids[submission_id]
track_gid = track_gids[fingerprint_id]
results[submission_id] = track_gid
return results
......@@ -3,3 +3,4 @@ flake8
functools32 ; python_version < "3.2"
mypy ; python_version >= "3"
sqlalchemy-stubs ; python_version >= "3"
grpcio-tools
......@@ -6,11 +6,19 @@
#
configparser==4.0.2 # via entrypoints, flake8
entrypoints==0.3 # via flake8
enum34==1.1.6 # via flake8
enum34==1.1.6 # via flake8, grpcio
flake8==3.7.8
functools32==3.2.3.post2 ; python_version < "3.2"
futures==3.3.0 # via grpcio
grpcio-tools==1.24.3
grpcio==1.24.3 # via grpcio-tools
mccabe==0.6.1 # via flake8
nose==1.3.7
protobuf==3.10.0 # via grpcio-tools
pycodestyle==2.5.0 # via flake8
pyflakes==2.1.1 # via flake8
six==1.12.0 # via grpcio, protobuf
typing==3.7.4.1 # via flake8
# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.4.0 # via protobuf
......@@ -6,12 +6,19 @@
#
entrypoints==0.3 # via flake8
flake8==3.7.8
grpcio-tools==1.24.3
grpcio==1.24.3 # via grpcio-tools
mccabe==0.6.1 # via flake8
mypy-extensions==0.4.2 # via mypy
mypy==0.730 ; python_version >= "3"
nose==1.3.7
protobuf==3.10.0 # via grpcio-tools
pycodestyle==2.5.0 # via flake8
pyflakes==2.1.1 # via flake8
six==1.12.0 # via grpcio, protobuf
sqlalchemy-stubs==0.2 ; python_version >= "3"
typed-ast==1.4.0 # via mypy
typing-extensions==3.7.4 # via mypy, sqlalchemy-stubs
# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.4.0 # via protobuf
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