From 209e1188829546d99b74e529bf326fffaca116fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Pe=C3=B1a?= Date: Tue, 19 Jul 2022 15:16:00 +0000 Subject: [PATCH] Fix(subsonic): missing default order for search3 --- api/funkwhale_api/common/utils.py | 2 +- api/funkwhale_api/subsonic/views.py | 2 +- changes/changelog.d/1782.bugfix | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changes/changelog.d/1782.bugfix diff --git a/api/funkwhale_api/common/utils.py b/api/funkwhale_api/common/utils.py index 061169ab8..f252aeac9 100644 --- a/api/funkwhale_api/common/utils.py +++ b/api/funkwhale_api/common/utils.py @@ -187,7 +187,7 @@ def order_for_search(qs, field): When searching, it's often more useful to have short results first, this function will order the given qs based on the length of the given field """ - return qs.annotate(__size=models.functions.Length(field)).order_by("__size") + return qs.annotate(__size=models.functions.Length(field)).order_by("__size", "pk") def recursive_getattr(obj, key, permissive=False): diff --git a/api/funkwhale_api/subsonic/views.py b/api/funkwhale_api/subsonic/views.py index 8ea2fba5a..dd5ca3111 100644 --- a/api/funkwhale_api/subsonic/views.py +++ b/api/funkwhale_api/subsonic/views.py @@ -566,7 +566,7 @@ class SubsonicViewSet(viewsets.GenericViewSet): except (TypeError, KeyError, ValueError): size = 20 - size = min(size, 100) + size = min(size, 500) queryset = c["queryset"] if query: queryset = c["queryset"].filter( diff --git a/changes/changelog.d/1782.bugfix b/changes/changelog.d/1782.bugfix new file mode 100644 index 000000000..81b2745e4 --- /dev/null +++ b/changes/changelog.d/1782.bugfix @@ -0,0 +1 @@ +Fixed unpredictable subsonic search3 results (#1782)