Open pastewka opened 3 years ago
I agree that sorting by date is more useful. You can always search by name.
Using the creation date is easier to implement, because the time of the last modification is not saved yet. But yes, the latter is more interesting - so you will also see first the surfaces which someone is working on.
The just use the creation date... We can always change this later.
I agree. Didn’t we also discuss adding some controls about how surfaces are sorted (user can choose by alpha or date or other, and ascending or descending)
Maybe that is a separate issue
@tdbjacobs , you're right that there is an issue, it's ContactEngineering/ce-ui#30. We could implement this here first and then the other.
Agreed. This one sounds easier to implement and should be the default anyway.
This is also related to ContactEngineering/topobank#757.
The whole frontend code for the seach results is here:
https://github.com/ContactEngineering/topobank/blob/main/topobank/frontend/manager/SearchResults.vue
You need to update the backend to respect search order. The respective view that returns the JSON to fancytree is here:
The sort order needs to be patched through to the database query in the Django backend.
Note that ListAPIView
is part of `django-rest-framework', the documentation can be found here: https://www.django-rest-framework.org/api-guide/generic-views/#listapiview
The sorting should probably occur in filtered_surfaces
, code is here:
To modify that function, you need to understand how Django QuerySet
s work. The documentation is here:
To have a template how to look for the new order_by
by parameter, look at how the category is determined. Insinde filtered_surfaces
the category is extracted here:
The get_category
function is defined here:
I suggest you use the same implementation style and add a get_order_by
function.
get_category
, get_sharing_status
and the new get_order_by
could actually become on function, something like get_query_parameter
that also does checking on whether the parameter is among the allowed choices.
I think there’s two different scenarios.
For someone browsing anonymously, I agree that sorting by date (newest) or even randomizing the order will keep it interesting.
When someone is searching for something specific, then the order probably doesn’t matter that much. Maybe some sort of “best-fit-to-search-terms” metric.
Tevis
Tevis Jacobs Mechanical Engineering and Materials Science University of Pittsburgh
From: Lars Pastewka @.> Sent: Friday, January 19, 2024 5:47:56 AM To: ContactEngineering/ce-ui @.> Cc: Tevis Jacobs @.>; Mention @.> Subject: [ContactEngineering/ce-ui] Add option to select search order (#35)
Right now, the surfaces are sorted by name. This means that in particular when browsing anonymously, it's always the same surface that shows up first. My suggestion is to sort by date with the newest shown first. This gives an impression of activity on the site. It also means that we should show the publication date in this list.
For unpublished surfaces, we should probably show the creation date or the last date of modification. (If would actually prefer the latter.)
Any thoughts @mcrothttps://github.com/mcrot @tdbjacobshttps://github.com/tdbjacobs ?
— Reply to this email directly, view it on GitHubhttps://github.com/ContactEngineering/ce-ui/issues/35, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFOUYWQ3LOEGMTB73WVNVKDYPJFNZAVCNFSM6AAAAABCBX2CPWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4TAMRUGUZTAMY. You are receiving this because you were mentioned.Message ID: @.***>
Right now, the surfaces are sorted by name. This means that in particular when browsing anonymously, it's always the same surface that shows up first. My suggestion is to sort by date with the newest shown first. This gives an impression of activity on the site. It also means that we should show the publication date in this list.
For unpublished surfaces, we should probably show the creation date or the last date of modification. (If would actually prefer the latter.)
Any thoughts @mcrot @tdbjacobs ?