From 6e55ccdafb3580ee593c09da638a462e6f0274cd Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 17 Sep 2015 12:05:11 +0200 Subject: [PATCH] Using last searching features in favourites calculation --- taiga/users/services.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/taiga/users/services.py b/taiga/users/services.py index 580d615b..e8df5362 100644 --- a/taiga/users/services.py +++ b/taiga/users/services.py @@ -29,6 +29,7 @@ from easy_thumbnails.files import get_thumbnailer from easy_thumbnails.exceptions import InvalidImageFormatError from taiga.base import exceptions as exc +from taiga.base.utils.db import to_tsquery from taiga.base.utils.urls import get_absolute_url from taiga.projects.notifications.choices import NotifyLevel from taiga.projects.notifications.services import get_projects_watched @@ -292,12 +293,10 @@ def get_favourites_list(for_user, from_user, type=None, action=None, q=None): filters_sql += " AND action = '{action}' ".format(action=action) if q: - # We must transform a q like "proj exam" (should find "project example") to something like proj:* & exam:* - qs = ["{}:*".format(e) for e in q.split(" ")] filters_sql += """ AND ( - to_tsvector(coalesce(subject,'') || ' ' ||coalesce(entities.name,'') || ' ' ||coalesce(to_char(ref, '999'),'')) @@ to_tsquery('{q}') + to_tsvector('english_nostop', coalesce(subject,'') || ' ' ||coalesce(entities.name,'') || ' ' ||coalesce(to_char(ref, '999'),'')) @@ to_tsquery('english_nostop', '{q}') ) - """.format(q=" & ".join(qs)) + """.format(q=to_tsquery(q)) sql = """ -- BEGIN Basic info: we need to mix info from different tables and denormalize it