Commit 3e74aae1 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Various fixes

parent b5cec7ab
......@@ -554,7 +554,7 @@ class SubmissionStatusHandlerParams(APIHandlerParams):
def parse(self, values, conn):
super(SubmissionStatusHandlerParams, self).parse(values, conn)
self._parse_client(values, conn)
self.ids = values.getlist('id')
self.ids = values.getlist('id', type=int)
class SubmissionStatusHandler(APIHandler):
......@@ -563,7 +563,7 @@ class SubmissionStatusHandler(APIHandler):
def _handle_internal(self, params):
response = {'submissions': [{'id': id, 'status': 'pending'} for id in params.ids]}
tracks = lookup_submission_status(self.conn, ids)
tracks = lookup_submission_status(self.conn, params.ids)
for submission in response['submissions']:
id = submission['id']
track_gid = tracks.get(id)
......@@ -626,7 +626,7 @@ class SubmitHandlerParams(APIHandlerParams):
super(SubmitHandlerParams, self).parse(values, conn)
self._parse_client(values, conn)
self._parse_user(values, conn)
self.wait = values.get('wait', type=int, default=1)
self.wait = values.get('wait', type=int, default=0)
self.submissions = []
suffixes = list(iter_args_suffixes(values, 'fingerprint'))
if not suffixes:
......@@ -685,7 +685,7 @@ class SubmitHandler(APIHandler):
tracks = {}
remaining = min(10, params.wait)
while remaining > 0 or not ids:
while remaining > 0 and ids:
time.sleep(0.5) # XXX replace with LISTEN/NOTIFY
remaining -= 0.5
tracks = lookup_submission_status(self.conn, ids)
......
......@@ -131,10 +131,10 @@ def lookup_submission_status(db, ids):
source = schema.fingerprint_source.\
join(schema.fingerprint).\
join(schema.track)
query = sql.select([schema.fingerprint_source.c.submission_id, schema.track.gid], from_obj=source).\
query = sql.select([schema.fingerprint_source.c.submission_id, schema.track.c.gid], from_obj=source).\
where(schema.fingerprint_source.c.submission_id.in_(ids))
results = {}
for id, track_gid in db.execute(query):
results[id] = track_id
results[id] = track_gid
return results
......@@ -23,7 +23,7 @@ api_url_rules = [
Submount('/v2', [
Rule('/lookup', endpoint=api.v2.LookupHandler),
Rule('/submit', endpoint=api.v2.SubmitHandler),
Rule('/submision_status', endpoint=api.v2.SubmissionStatusHandler),
Rule('/submission_status', endpoint=api.v2.SubmissionStatusHandler),
Rule('/track/list_by_mbid', endpoint=api.v2.misc.TrackListByMBIDHandler),
Rule('/track/list_by_puid', endpoint=api.v2.misc.TrackListByPUIDHandler),
Rule('/user/lookup', endpoint=api.v2.misc.UserLookupHandler),
......
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