Commit 7987ce27 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed wrong proc calc indexes.

parent 7a968396
Pipeline #47375 passed with stages
in 17 minutes and 47 seconds
......@@ -260,7 +260,7 @@ class UploadResource(Resource):
try:
page = int(request.args.get('page', 1))
per_page = int(request.args.get('per_page', 10))
order_by = str(request.args.get('order_by', 'mainfile'))
order_by = request.args.get('order_by', None)
order = int(str(request.args.get('order', -1)))
except Exception:
abort(400, message='invalid pagination or ordering')
......@@ -271,12 +271,14 @@ class UploadResource(Resource):
except AssertionError:
abort(400, message='invalid pagination')
if order_by not in ['mainfile', 'tasks_status', 'parser']:
abort(400, message='invalid order_by field %s' % order_by)
if order_by is not None:
order_by = str(order_by)
if order_by not in ['mainfile', 'tasks_status', 'parser']:
abort(400, message='invalid order_by field %s' % order_by)
order_by = ('-%s' if order == -1 else '+%s') % order_by
order_by = ('-%s' if order == -1 else '+%s') % order_by
calcs = upload.all_calcs((page - 1) * per_page, page * per_page, order_by)
calcs = upload.all_calcs((page - 1) * per_page, page * per_page, order_by=order_by)
failed_calcs = upload.failed_calcs
result = ProxyUpload(upload, {
'pagination': dict(
......
......@@ -961,7 +961,7 @@ class NomadCOEMigration:
for page in range(1, math.ceil(upload_total_calcs / per_page) + 1):
upload = self.call_api(
'uploads.get_upload', upload_id=upload.upload_id, per_page=per_page,
page=page, order_by='mainfile')
page=page)
for calc_proc in upload.calcs.results:
calc_logger = logger.bind(
......
......@@ -68,7 +68,11 @@ class Calc(Proc):
meta: Any = {
'indexes': [
'upload_id', 'mainfile', 'parser', 'tasks_status', 'process_status'
'upload_id',
('upload_id', 'mainfile'),
('upload_id', 'parser'),
('upload_id', 'tasks_status'),
('upload_id', 'process_status')
]
}
......@@ -697,8 +701,9 @@ class Upload(Proc):
def pending_calcs(self):
return Calc.objects(upload_id=self.upload_id, tasks_status=PENDING).count()
def all_calcs(self, start, end, order_by='mainfile'):
return Calc.objects(upload_id=self.upload_id)[start:end].order_by(order_by)
def all_calcs(self, start, end, order_by=None):
query = Calc.objects(upload_id=self.upload_id)[start:end]
return query.order_by(order_by) if order_by is not None else query
@property
def calcs(self):
......
......@@ -274,6 +274,10 @@ class TestUploads:
return upload
elif rv.status_code == 404:
return None
else:
raise Exception(
'unexpected status code while blocking for upload processing: %s' %
str(rv.status_code))
def assert_upload_does_not_exist(self, client, upload_id: str, test_user_auth):
self.block_until_completed(client, upload_id, test_user_auth)
......
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