Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

records: sort by most recent descending by default #319

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,26 +524,32 @@ def _(x):
}
"""REST search facets."""

RECORDS_REST_SORT_OPTIONS = dict(documents=dict(
bestmatch=dict(
title=_('Best match'),
fields=['-_score'],
default_order='asc',
order=2,
),
mostrecent=dict(
title=_('Most recent'),
fields=['-_created'],
default_order='desc',
order=1,
),
))
INDEXES = ['documents', 'organisations', 'users', 'deposits']

RECORDS_REST_SORT_OPTIONS = {}
for index in INDEXES:
RECORDS_REST_SORT_OPTIONS[index] = {
'mostrecent': {
'title': _('Most recent'),
'fields': ['-_created'],
'default_order': 'desc',
'order': 1,
},
'bestmatch': {
'title': _('Best match'),
'fields': ['-_score'],
'default_order': 'asc',
'order': 2,
}
}
"""Setup sorting options."""

RECORDS_REST_DEFAULT_SORT = dict(documents=dict(
query='bestmatch',
noquery='mostrecent',
), )
RECORDS_REST_DEFAULT_SORT = {}
for index in INDEXES:
RECORDS_REST_DEFAULT_SORT[index] = {
'query': 'bestmatch',
'noquery': 'mostrecent'
}
"""Set default sorting options."""

RECORDS_FILES_REST_ENDPOINTS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@
"type": "keyword"
}
}
},
"_created": {
"type": "date"
},
"_updated": {
"type": "date"
}
}
}
Expand Down