Skip to content

Commit

Permalink
drafts search options fix (#256)
Browse files Browse the repository at this point in the history
Co-authored-by: Ronald Krist <[email protected]>
  • Loading branch information
SilvyPuzzlewell and Ronald Krist authored Feb 17, 2025
1 parent 08ee8b3 commit e071d6c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
35 changes: 31 additions & 4 deletions oarepo_runtime/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from invenio_rdm_records.services.config import (
RDMSearchDraftsOptions as BaseRDMSearchDraftsOptions,
)
from invenio_rdm_records.services.config import (
RDMSearchOptions as BaseRDMSearchOptions,
)
from invenio_rdm_records.services.config import RDMSearchOptions as BaseRDMSearchOptions
from invenio_records_resources.proxies import current_service_registry
from invenio_records_resources.services.records import (
SearchOptions as InvenioSearchOptions,
Expand Down Expand Up @@ -86,6 +84,35 @@ def params_interpreters_cls(cls):
}


class SearchOptionsDraftMixin(SearchOptionsMixin):
sort_options = {
"bestmatch": dict(
title=_("Best match"),
fields=["_score"], # search defaults to desc on `_score` field
),
"updated-desc": dict(
title=_("Recently updated"),
fields=["-updated"],
),
"updated-asc": dict(
title=_("Least recently updated"),
fields=["updated"],
),
"newest": dict(
title=_("Newest"),
fields=["-created"],
),
"oldest": dict(
title=_("Oldest"),
fields=["created"],
),
"version": dict(
title=_("Version"),
fields=["-versions.index"],
),
}


class SearchOptions(SearchOptionsMixin, InvenioSearchOptions):
# TODO: should be changed
params_interpreters_cls = [
Expand All @@ -100,7 +127,7 @@ class RDMSearchOptions(SearchOptionsMixin, BaseRDMSearchOptions):
pass


class RDMSearchDraftsOptions(SearchOptionsMixin, BaseRDMSearchDraftsOptions):
class RDMSearchDraftsOptions(SearchOptionsDraftMixin, BaseRDMSearchDraftsOptions):
pass


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-runtime
version = 1.5.93
version = 1.5.94
description = A set of runtime extensions of Invenio repository
authors = Alzbeta Pokorna
readme = README.md
Expand Down

0 comments on commit e071d6c

Please sign in to comment.