Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
34151e9b
Commit
34151e9b
authored
Mar 16, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not use weights for search, we ignore them anyway
parent
a6a9bb88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
trans/managers.py
trans/managers.py
+2
-1
No files found.
trans/managers.py
View file @
34151e9b
...
@@ -219,6 +219,8 @@ class UnitManager(models.Manager):
...
@@ -219,6 +219,8 @@ class UnitManager(models.Manager):
if
rows
==
([],
[]):
if
rows
==
([],
[]):
return
self
.
none
()
return
self
.
none
()
return
self
.
filter
(
pk__in
=
[
row
[
0
]
for
row
in
rows
])
# apply the weights to each row
# apply the weights to each row
weights
=
[(
w
,
weight_fn
(
rows
))
for
w
,
weight_fn
in
settings
.
SEARCH_WEIGHTS
]
weights
=
[(
w
,
weight_fn
(
rows
))
for
w
,
weight_fn
in
settings
.
SEARCH_WEIGHTS
]
...
@@ -228,7 +230,6 @@ class UnitManager(models.Manager):
...
@@ -228,7 +230,6 @@ class UnitManager(models.Manager):
for
document
in
total_scores
:
for
document
in
total_scores
:
total_scores
[
document
]
+=
weight
*
scores
[
document
]
total_scores
[
document
]
+=
weight
*
scores
[
document
]
return
self
.
filter
(
pk__in
=
total_scores
.
keys
())
# sort by the calculated weights and return
# sort by the calculated weights and return
# return sorted([(Unit.objects.get(pk = doc), score) for (doc, score) in total_scores.iteritems()], reverse=1)
# return sorted([(Unit.objects.get(pk = doc), score) for (doc, score) in total_scores.iteritems()], reverse=1)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment