From 40d7e6da376d8f4c8fe86768cdf24bfd83961b00 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 25 Mar 2022 17:28:17 +0700 Subject: [PATCH] add secondary sort for channel and title, #193 --- tubearchivist/home/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index d75566c..d8c34ea 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -264,6 +264,13 @@ class HomeView(ArchivistResultsView): def _update_view_data(self): """update view specific data dict""" + self.data["sort"].extend( + [ + {"channel.channel_name.keyword": {"order": "asc"}}, + {"title.keyword": {"order": "asc"}}, + ] + ) + if self.context["hide_watched"]: self.data["query"] = {"term": {"player.watched": {"value": False}}} if self.search_get: @@ -425,14 +432,14 @@ class ChannelIdView(ArchivistResultsView): def _update_view_data(self, channel_id): """update view specific data dict""" - query = { + self.data["query"] = { "bool": { "must": [ {"term": {"channel.channel_id": {"value": channel_id}}} ] } } - self.data["query"] = query + self.data["sort"].append({"title.keyword": {"order": "asc"}}) if self.context["hide_watched"]: to_append = {"term": {"player.watched": {"value": False}}}