From bc19ff0a7b5d35ab5c090cafe149be82b5646c52 Mon Sep 17 00:00:00 2001 From: p0psicles Date: Fri, 13 Aug 2021 12:26:26 +0200 Subject: [PATCH 1/2] Group history compact layout results by quality --- medusa/server/api/v2/history.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/medusa/server/api/v2/history.py b/medusa/server/api/v2/history.py index 0ea61e80f5..53ebcb51f5 100644 --- a/medusa/server/api/v2/history.py +++ b/medusa/server/api/v2/history.py @@ -140,6 +140,8 @@ def get(self, series_slug, path_param): if item.get('showid') and item.get('season') and item.get('episode') and item.get('indexer_id'): item['showslug'] = f"{indexer_id_to_name(item['indexer_id'])}{item['showid']}" my_key = f"{item['showslug']}S{item['season']}E{item['episode']}" + if item.get('quality'): + my_key += f"Q{item['quality']}" res.setdefault(my_key, []).append(item) results = res headers['X-Pagination-Count'] = len(results) From fd758a407085131f7203286347ac75df72fd99b5 Mon Sep 17 00:00:00 2001 From: p0psicles Date: Fri, 13 Aug 2021 12:29:32 +0200 Subject: [PATCH 2/2] Refactor. Quality is always available. --- medusa/server/api/v2/history.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/medusa/server/api/v2/history.py b/medusa/server/api/v2/history.py index 53ebcb51f5..f504d88474 100644 --- a/medusa/server/api/v2/history.py +++ b/medusa/server/api/v2/history.py @@ -139,10 +139,8 @@ def get(self, series_slug, path_param): for item in results: if item.get('showid') and item.get('season') and item.get('episode') and item.get('indexer_id'): item['showslug'] = f"{indexer_id_to_name(item['indexer_id'])}{item['showid']}" - my_key = f"{item['showslug']}S{item['season']}E{item['episode']}" - if item.get('quality'): - my_key += f"Q{item['quality']}" - res.setdefault(my_key, []).append(item) + group_by_key = f"{item['showslug']}S{item['season']}E{item['episode']}Q{item['quality']}" + res.setdefault(group_by_key, []).append(item) results = res headers['X-Pagination-Count'] = len(results)