Skip to content

Commit

Permalink
fix: ruff baby
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyaldebert committed Oct 17, 2024
1 parent 58ea752 commit 7e02bb9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions udata/core/dataservices/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def delete(self, dataservice):

return "", 204


@ns.route("/<dataservice:dataservice>/rdf", endpoint="dataservice_rdf", doc=common_doc)
@api.response(404, "Dataservice not found")
@api.response(410, "Dataservice has been deleted")
Expand Down
1 change: 1 addition & 0 deletions udata/core/dataservices/apiv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

search_parser = DataserviceSearch.as_request_parser()


@ns.route("/search/", endpoint="dataservice_search")
class DataserviceSearchAPI(API):
"""Dataservices collection search endpoint"""
Expand Down
17 changes: 11 additions & 6 deletions udata/core/dataservices/search.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import datetime

from udata.api.parsers import ModelApiParser
from udata.api import api
from bson.objectid import ObjectId

from udata.api import api
from udata.api.parsers import ModelApiParser
from udata.models import Dataservice, Organization, User
from udata.search import (
BoolFilter,
Expand All @@ -17,6 +18,7 @@

DEFAULT_SORTING = "-created_at"


class DataserviceApiParser(ModelApiParser):
sorts = {
"created": "created_at",
Expand Down Expand Up @@ -45,7 +47,6 @@ def parse_filters(dataservices, args):
return dataservices



@register
class DataserviceSearch(ModelSearchAdapter):
model = Dataservice
Expand Down Expand Up @@ -76,7 +77,9 @@ def mongo_search(cls, args):
or DEFAULT_SORTING
)
offset = (args["page"] - 1) * args["page_size"]
return dataservices.order_by(sort).skip(offset).limit(args["page_size"]), dataservices.count()
return dataservices.order_by(sort).skip(offset).limit(
args["page_size"]
), dataservices.count()

@classmethod
def serialize(cls, dataservice: Dataservice) -> dict:
Expand All @@ -100,9 +103,11 @@ def serialize(cls, dataservice: Dataservice) -> dict:
"id": str(dataservice.id),
"title": dataservice.title,
"description": dataservice.description,
"base_api_url ": dataservice.base_api_url ,
"base_api_url ": dataservice.base_api_url,
"created_at": to_iso_datetime(dataservice.created_at),
"archived": to_iso_datetime(dataservice.archived_at) if dataservice.archived_at else None,
"archived": to_iso_datetime(dataservice.archived_at)
if dataservice.archived_at
else None,
"organization": organization,
"owner": str(owner.id) if owner else None,
"tags": dataservice.tags,
Expand Down

0 comments on commit 7e02bb9

Please sign in to comment.