mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Joining when sorting by size.
This commit is contained in:
parent
7c1cc07365
commit
ac06a9b8b2
2 changed files with 8 additions and 0 deletions
|
|
@ -382,6 +382,7 @@ ORDER_GROUP_BYS = {
|
|||
'size': 'fg.size, fg.primary_path',
|
||||
'-size': 'fg.size, fg.primary_path',
|
||||
}
|
||||
FILE_ORDERS = ['size', '-size']
|
||||
|
||||
|
||||
def search_archives(search_str: str, domain: str, limit: int, offset: int, order: str, tag_names: List[str],
|
||||
|
|
@ -409,6 +410,8 @@ def search_archives(search_str: str, domain: str, limit: int, offset: int, order
|
|||
try:
|
||||
order_by = ARCHIVE_ORDERS[order]
|
||||
group_by = f'{group_by}, {ORDER_GROUP_BYS[order]}'
|
||||
if order in FILE_ORDERS:
|
||||
joins = ['LEFT JOIN file_group fg ON fg.id = a.file_group_id']
|
||||
except KeyError:
|
||||
raise InvalidOrderBy(f'Invalid order by: {order}')
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ def test_archives_search_order(test_session, archive_directory, archive_factory,
|
|||
if not response.status_code == HTTPStatus.OK:
|
||||
raise AssertionError(str(response.json))
|
||||
|
||||
data = {'search_str': None, 'order_by': order_by}
|
||||
request, response = test_client.post('/api/archive/search', content=json.dumps(data))
|
||||
if not response.status_code == HTTPStatus.OK:
|
||||
raise AssertionError(str(response.json))
|
||||
|
||||
|
||||
def test_archives_search(test_session, archive_directory, archive_factory, test_client):
|
||||
"""Archives can be searched by their title and their contents."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue