@@ -225,10 +225,11 @@ def get_queryset(self):
225225 # For performance reasons we filter first by similarity, which relies on an
226226 # index, then only calculate precise similarity scores for sorting purposes.
227227 #
228- # Additionally we reorder results to prefer users "closer" to the current
228+ # Additionally results are reordered to prefer users "closer" to the current
229229 # user: users they recently shared documents with, same full domain, same
230230 # partial domain (e.g. both end with "gouv.fr"). To achieve that without
231- # complex SQL we build a proximity score in Python and returnthe top N results.
231+ # complex SQL, we build a proximity score in Python and return the
232+ # top N results.
232233 current_user = self .request .user
233234 shared_map = users_sharing_documents_with (current_user )
234235
@@ -287,9 +288,6 @@ def _sort_key(u):
287288 sim ,
288289 )
289290
290- # Sort candidates by the key descending and return top N as a queryset-like
291- # list. Keep return type consistent with previous behavior (QuerySet slice
292- # was returned) by returning a list of model instances.
293291 candidates .sort (key = _sort_key , reverse = True )
294292
295293 return candidates [: settings .API_USERS_LIST_LIMIT ]
@@ -2295,7 +2293,8 @@ def get_queryset(self):
22952293 )
22962294 # Abilities are computed based on logged-in user's role and
22972295 # the user role on each document access
2298- .annotate (user_roles = db .Subquery (user_roles_query )).distinct ()
2296+ .annotate (user_roles = db .Subquery (user_roles_query ))
2297+ .distinct ()
22992298 )
23002299 return queryset
23012300
0 commit comments