From c7fc0e96104cb08c8dd8cd90205570d3c0af784e Mon Sep 17 00:00:00 2001 From: hernani Date: Wed, 4 May 2011 17:55:13 +0000 Subject: [PATCH] Makes related questions search work with weighted results. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1021 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/commands.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/forum/views/commands.py b/forum/views/commands.py index 0b54126..f34619a 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -534,6 +534,10 @@ def matching_users(request): def related_questions(request): if request.POST and request.POST.get('title', None): can_rank, questions = Question.objects.search(request.POST['title']) + + if can_rank and isinstance(can_rank, basestring): + questions = questions.order_by(can_rank) + return HttpResponse(simplejson.dumps( [dict(title=q.title, url=q.get_absolute_url(), score=q.score, summary=q.summary) for q in questions.filter_state(deleted=False)[0:10]]), mimetype="application/json") -- 2.39.5