Skip to content

Commit

Permalink
records_relations: Set default sort_by to None in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 authored and kpsherva committed Apr 4, 2024
1 parent 5b1bb6b commit 281494a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions invenio_app_ils/records_relations/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def get(self):

# Pre-requisite: fields being sorted should be of the same type.
# Sort by the keys available in the data in order
relations.get(name, []).sort(
key=lambda rec: [rec.get(key) for key in relation_type.sort_by]
)
if relation_type.sort_by:
relations.get(name, []).sort(
key=lambda rec: [rec.get(key) for key in relation_type.sort_by]
)

return relations

Expand Down
10 changes: 5 additions & 5 deletions invenio_app_ils/relations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"invenio_app_ils.relations.nodes:PIDNodeRelated",
"invenio_pidrelations.serializers.schemas.RelationSchema",
"invenio_app_ils.relations.api.SiblingsRelation",
[],
None,
)
EDITION_RELATION = ILS_RELATION_TYPE(
1,
Expand All @@ -45,7 +45,7 @@
"invenio_app_ils.relations.nodes:PIDNodeRelated",
"invenio_pidrelations.serializers.schemas.RelationSchema",
"invenio_app_ils.relations.api.SiblingsRelation",
[],
None,
)
MULTIPART_MONOGRAPH_RELATION = ILS_RELATION_TYPE(
3,
Expand All @@ -54,7 +54,7 @@
"invenio_app_ils.relations.nodes:PIDNodeRelated",
"invenio_pidrelations.serializers.schemas.RelationSchema",
"invenio_app_ils.relations.api.ParentChildRelation",
[],
None,
)
SERIAL_RELATION = ILS_RELATION_TYPE(
4,
Expand All @@ -63,7 +63,7 @@
"invenio_app_ils.relations.nodes:PIDNodeRelated",
"invenio_pidrelations.serializers.schemas.RelationSchema",
"invenio_app_ils.relations.api.ParentChildRelation",
[],
None,
)
SEQUENCE_RELATION = ILS_RELATION_TYPE(
5,
Expand All @@ -72,7 +72,7 @@
"invenio_app_ils.relations.nodes:PIDNodeRelated",
"invenio_pidrelations.serializers.schemas.RelationSchema",
"invenio_app_ils.relations.api.SequenceRelation",
[],
None,
)


Expand Down

0 comments on commit 281494a

Please sign in to comment.