feat: add sorting by file size#1330
Conversation
| if is_size_sort: | ||
| ids = self._sort_ids_by_file_size(ids, search.ascending) | ||
|
|
There was a problem hiding this comment.
This breaks when the query has a LIMIT due to the page size.
There was a problem hiding this comment.
Changed the sort logic to handle the query having page size.
|
Also, unless you speak 19 languages those are AI/machine translations and I would prefer not having those in here. Because while I'm not sure whether we have an official policy on AI/machine translations, I would personally prefer a high quality of translations over a high quantity (and people are less likely to contribute when translations are suboptimal rather than missing), so I would prefer a missing translation over an AI one (also should we redecide in the future we can do the AI translations ourselves, where as we won't have any idea how good our translations are if we allow AI translations). |
Summary
core/library/alchemy/enums.py: AddedSIZE = "file.size"toSortingModeEnumcore/library/alchemy/library.pysearch_library(): when SIZE mode is active, skips SQL ordering (falls back to Entry.id) and calls_sort_ids_by_file_size()after the query returns._sort_ids_by_file_size(): bulk-fetches all entry paths in one query, calls stat().st_size on each file, returns the IDs sorted by size. Missing/unlinked files get size -1 and sort to the front (ascending).Added "file.size" key with a proper translation in each translation file.
tests/test_search.py: Four new tests.This implements the file size sort option requested in 207
Tasks Completed