From: hernani Date: Wed, 4 May 2011 17:55:13 +0000 (+0000) Subject: Makes related questions search work with weighted results. X-Git-Tag: live~292 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/c7fc0e96104cb08c8dd8cd90205570d3c0af784e Makes related questions search work with weighted results. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1021 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- 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")