]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/handlers.py
Delted questions were not updating tag count.
[osqa.git] / forum_modules / pgfulltext / handlers.py
1 from forum.models.question import Question, QuestionManager
2 from forum.modules.decorators import decorate
3
4 @decorate(QuestionManager.search, needs_origin=False)
5 def question_search(self, keywords):
6     return self.extra(
7                     tables=['forum_rootnode_doc'],
8                     select={
9                         'ranking': 'ts_rank_cd(\'{0.1, 0.2, 0.8, 1.0}\'::float4[], "forum_rootnode_doc"."document", plainto_tsquery(\'english\', %s), 32)',
10                     },
11                     where=['"forum_rootnode_doc"."node_id" = "forum_node"."id"', '"forum_rootnode_doc"."document" @@ plainto_tsquery(\'english\', %s)'],
12                     params=[keywords],
13                     select_params=[keywords],
14                     order_by=['-ranking']
15                 )