Ordering of search results in GraphQL API and UI
Gathering this in a single issue although I don't expect it will be implemented in a single PR.
A good starter would be:
- size
- torrent created at
- name
- seeders, leechers (a bit more complicated needs to get a max from torrents_torrent_sources table)
Will need familiarity with the existing search implementation; currently the domain-specific search code lives here: https://github.com/bitmagnet-io/bitmagnet/tree/main/internal/database/search
So I imagine these files would be called things like:
internal/database/search/order_torrent_created_at.goetc...
There are a couple of simple examples of ordering here: https://github.com/bitmagnet-io/bitmagnet/blob/main/internal/database/query/options.go#L117
I'd envisage a search parameter with enums that could be passed as an array, e.g. order: [size_desc, created_desc, name_asc].
For the UI a simple dropdown next to the search input would probably suffice for now, with links on the relevant table headers.
Seconding this, as far as the UI, links on the relevant table headers would be excellent. ie if I click "Size", it should show all the largest results first, if I click again, it should show all the smallest, etc.
I really have to add my support for this. I have 433,000+ results, and most of them are 0 or 1 seeders, and I can't even begin to meaningfully explore these for interesting files without being able to either sort or filter based on things like seeders or size.
Ordering capability has been added in https://github.com/bitmagnet-io/bitmagnet/pull/260