Commit 2b020c02 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed HTTP 500 on order_by non str quantities in entry v1 API. #468

parent 73bb98d4
......@@ -1058,7 +1058,8 @@ def _es_to_api_aggregation(es_response, name: str, agg: Aggregation) -> Aggregat
if order_by is None:
pagination.next_after = after_key[name]
else:
pagination.next_after = ':'.join(after_key.to_dict().values())
str_values = [str(v) for v in after_key.to_dict().values()]
pagination.next_after = ':'.join(str_values)
return AggregationResponse(data=agg_data, pagination=pagination, **aggregation_dict)
......
......@@ -519,7 +519,9 @@ def test_entries_all_statistics(client, data):
@pytest.mark.parametrize('aggregation, total, size, status_code', [
pytest.param({'quantity': 'upload_id', 'pagination': {'order_by': 'uploader'}}, 3, 3, 200, id='order'),
pytest.param({'quantity': 'upload_id', 'pagination': {'order_by': 'uploader'}}, 3, 3, 200, id='order-str'),
pytest.param({'quantity': 'upload_id', 'pagination': {'order_by': 'upload_time'}}, 3, 3, 200, id='order-date'),
pytest.param({'quantity': 'upload_id', 'pagination': {'order_by': 'dft.n_calculations'}}, 3, 3, 200, id='order-int'),
pytest.param({'quantity': 'dft.labels_springer_classification'}, 0, 0, 200, id='no-results'),
pytest.param({'quantity': 'upload_id', 'pagination': {'after': 'id_published'}}, 3, 1, 200, id='after'),
pytest.param({'quantity': 'upload_id', 'pagination': {'order_by': 'uploader', 'after': 'Sheldon Cooper:id_published'}}, 3, 1, 200, id='after-order'),
......
Supports Markdown
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