ContactEngineering / ce-ui

User interface of contact.engineering
https://contact.engineering
MIT License
0 stars 0 forks source link

Add option to select search order #35

Open pastewka opened 3 years ago

pastewka commented 3 years ago

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 ?

mcrot commented 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.

pastewka commented 3 years ago

The just use the creation date... We can always change this later.

tdbjacobs commented 3 years ago

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

mcrot commented 3 years ago

@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.

tdbjacobs commented 3 years ago

Agreed. This one sounds easier to implement and should be the default anyway.

mcrot commented 2 years ago

This is also related to ContactEngineering/topobank#757.

pastewka commented 1 year ago

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:

https://github.com/ContactEngineering/topobank/blob/2e6d58be5dc0f29b0c5b97af0795699dc67272d1/topobank/manager/views.py#L1806

The sort order needs to be patched through to the database query in the Django backend.

pastewka commented 12 months ago

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

pastewka commented 12 months ago

The sorting should probably occur in filtered_surfaces, code is here:

https://github.com/ContactEngineering/topobank/blob/2e6d58be5dc0f29b0c5b97af0795699dc67272d1/topobank/manager/utils.py#L203

pastewka commented 12 months ago

To modify that function, you need to understand how Django QuerySets work. The documentation is here:

https://docs.djangoproject.com/en/4.2/ref/models/querysets/

pastewka commented 12 months ago

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:

https://github.com/ContactEngineering/topobank/blob/2e6d58be5dc0f29b0c5b97af0795699dc67272d1/topobank/manager/utils.py#L228C21-L228C21

The get_category function is defined here:

https://github.com/ContactEngineering/topobank/blob/2e6d58be5dc0f29b0c5b97af0795699dc67272d1/topobank/manager/utils.py#L956

I suggest you use the same implementation style and add a get_order_by function.

pastewka commented 12 months ago

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.

tdbjacobs commented 5 months ago

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: @.***>