Skip to content

Commit

Permalink
correct template and fix no-pagination (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshunayan committed Jul 31, 2020
1 parent d2428fe commit 0fadcb4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hydrus/data/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ def pagination(filtered_instances, path, type_, API_NAME,
collection_template["members"].append(object_template)

# If pagination is disabled then stop and return the collection template
collection_template["hydra:totalItems"] = result_length
if paginate is False:
return collection_template
collection_template["hydra:totalItems"] = result_length
# Calculate last page number
if result_length != 0 and result_length % page_size == 0:
last = result_length // page_size
Expand Down
5 changes: 2 additions & 3 deletions hydrus/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ def add_iri_template(path: str, API_NAME: str) -> Dict[str, Any]:
:return: Hydra IriTemplate .
"""
template_mappings = list()
template = f"/{API_NAME}/{path}("
first = True
template = f"/{API_NAME}/{path}{{?"
template, template_mappings = generate_iri_mappings(path, template,
template_mapping=template_mappings,)

Expand Down Expand Up @@ -287,7 +286,7 @@ def add_pagination_iri_mappings(template: str,
for i in range(len(paginate_variables)):
# If final variable then do not add space and comma and add the final parentheses
if i == len(paginate_variables) - 1:
template += f"{paginate_variables[i]})"
template += f"{paginate_variables[i]}}}"
else:
template += f"{paginate_variables[i]}, "
mapping = IriTemplateMapping(variable=paginate_variables[i], prop=paginate_variables[i])
Expand Down
3 changes: 2 additions & 1 deletion hydrus/item_collection_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Helper functions for Item Collection"""

import json
import sys
from functools import partial

from flask import Response, jsonify, request, abort
Expand Down Expand Up @@ -72,7 +73,7 @@ def item_collection_get_response(path: str) -> Response:
page_size=get_page_size())
else:
# Get whole collection
response = crud_response(paginate=False)
response = crud_response(paginate=False, page_size=sys.maxsize)

response["search"] = add_iri_template(path=class_path,
API_NAME=api_name)
Expand Down

0 comments on commit 0fadcb4

Please sign in to comment.