Skip to content

Commit

Permalink
feat: resource type to search facets
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgualdi committed Jul 9, 2024
1 parent 052e7ca commit 1d4afcb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
17 changes: 15 additions & 2 deletions invenio_records_marc21/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"field": "is_published",
},
},
"resource_type": {
"facet": facets.resource_type,
"ui": {
"field": "metadata.resource_type",
},
},
"file_type": {
"facet": facets.filetype,
"ui": {
Expand Down Expand Up @@ -83,7 +89,11 @@
}

MARC21_SEARCH_DRAFTS = {
"facets": ["access_status", "is_published", "file_type"],
"facets": [
"resource_type",
"access_status",
"is_published",
],
"sort": [
"bestmatch",
"newest",
Expand All @@ -94,7 +104,10 @@
"""User records search configuration (i.e. list of uploads)."""

MARC21_SEARCH = {
"facets": ["access_status", "file_type"],
"facets": [
"resource_type",
"access_status",
],
"sort": [
"bestmatch",
"newest",
Expand Down
2 changes: 2 additions & 0 deletions invenio_records_marc21/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Marc21SearchOptions(SearchOptions, SearchOptionsMixin):

facets = {
"access_status": rdm_facets.access_status,
"resource_type": facets.resource_type,
}


Expand All @@ -61,6 +62,7 @@ class Marc21SearchDraftsOptions(SearchDraftsOptions, SearchOptionsMixin):
facets = {
"access_status": rdm_facets.access_status,
"is_published": facets.is_published,
"resource_type": facets.resource_type,
}


Expand Down
12 changes: 12 additions & 0 deletions invenio_records_marc21/services/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from invenio_i18n import gettext as _
from invenio_records_resources.services.records.facets import TermsFacet

from ..records.fields.resourcetype import ResourceTypeEnum

is_published = TermsFacet(
field="is_published",
label=_("Status"),
Expand All @@ -26,3 +28,13 @@
label=_("File type"),
value_labels=lambda ids: {id: id.upper() for id in ids},
)


resource_type = TermsFacet(
field="metadata.fields.970.subfields.d",
label=_("Resource type"),
value_labels={
ResourceTypeEnum.HSMASTER.value: _("Masterthesis"),
ResourceTypeEnum.HSDISS.value: _("Dissertation"),
},
)

0 comments on commit 1d4afcb

Please sign in to comment.