From 497d7770c6139dbeaf2aade8050e705846e502f9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 17 Feb 2019 17:16:25 +0100 Subject: [PATCH] Better way to group by media path --- platypush/plugins/media/local.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platypush/plugins/media/local.py b/platypush/plugins/media/local.py index 3f66907349..3756aeab85 100644 --- a/platypush/plugins/media/local.py +++ b/platypush/plugins/media/local.py @@ -210,12 +210,12 @@ class LocalMediaSearcher: query_tokens = [_.lower() for _ in re.split( self._filename_separators, query.strip())] - for file_record in session.query(MediaFile). \ + for file_record in session.query(MediaFile.path). \ join(MediaFileToken). \ join(MediaToken). \ filter(MediaToken.token.in_(query_tokens)). \ - group_by(MediaFile.id). \ - order_by(func.count(MediaFileToken.token_id)): + group_by(MediaFile.path). \ + order_by(func.count(MediaFileToken.token_id).desc()): results[file_record.path] = { 'url': 'file://' + file_record.path, 'title': os.path.basename(file_record.path),