Skip to content

Commit

Permalink
Fix wrong name for objects in pager
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudDauce committed Aug 20, 2024
1 parent aabc831 commit c9a70ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
17 changes: 9 additions & 8 deletions udata/api_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,16 @@ def apply_sort_filters_and_pagination(base_query):
and getattr(cls, "__elasticsearch_search__", None) is not None
):
# Do an Elasticsearch query
print(cls.__elasticsearch_search__(args.get("q")))
print(
{
"data": cls.__elasticsearch_search__(args.get("q")),
results = cls.__elasticsearch_search__(args.get("q"))
if paginable:
return {
"objects": results, # restx pager rename `objects` into `data`
"total": len(results),
"page": 1,
"page_size": len(results),
}
)
return {
"data": cls.__elasticsearch_search__(args.get("q")),
}
else:
return results
else:
# Do a regular MongoDB query
if sortables and args["sort"]:
Expand Down
6 changes: 1 addition & 5 deletions udata/core/dataservices/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ def get(self):
"""List or search all dataservices"""
query = Dataservice.objects.visible()

results = Dataservice.apply_sort_filters_and_pagination(query)
print(results)

print("here")
return results
return Dataservice.apply_sort_filters_and_pagination(query)

@api.secure
@api.doc("create_dataservice", responses={400: "Validation error"})
Expand Down
5 changes: 1 addition & 4 deletions udata/tests/api/test_dataservices_api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import random
import string
import time
from datetime import datetime

from elasticsearch_dsl import analyzer, token_filter, tokenizer
from flask import url_for

from udata.core.badges.models import Badge
Expand All @@ -12,7 +9,7 @@
from udata.core.dataset.factories import DatasetFactory, LicenseFactory
from udata.core.organization.constants import CERTIFIED, PUBLIC_SERVICE
from udata.core.organization.factories import OrganizationFactory
from udata.core.organization.models import Member, Organization
from udata.core.organization.models import Member
from udata.core.user.factories import UserFactory
from udata.i18n import gettext as _

Expand Down

0 comments on commit c9a70ca

Please sign in to comment.