Merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde into lp:ocb-addons

Proposed by Alexandre Fayolle - camptocamp
Status: Rejected
Rejected by: Holger Brunn (Therp)
Proposed branch: lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde
Merge into: lp:ocb-addons
Diff against target: 25 lines (+7/-1)
1 file modified
document/document.py (+7/-1)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Disapprove
Yannick Vaucher @ Camptocamp code review, no test Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Lionel Sausin - Initiatives/Numérigraphe (community) Needs Fixing
Leonardo Pistone code review Approve
Review via email: mp+214486@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :
review: Approve (code review)
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

- "id" is not a great variable name, python has id() already.
- wouldn't it be the same to write "result = list(ids)" at line 21?

review: Needs Fixing
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> - wouldn't it be the same to write "result = list(ids)" at line 21?

`list(ids)` wouldn't keep the order of ids.

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

I see, line 21 it deserves a comment then.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Development for 7.0 has moved to github on https://github.com/OCA/ocb - please move your merge proposal there if it is still valid.

(I close and reject this in order to have a cleaner overview for 6.1 MPs which indeed have to be done on launchpad)

review: Disapprove

Unmerged revisions

10077. By Romain Deheele - Camptocamp

[FIX] document: search method overload should take into account order by clause

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'document/document.py'
2--- document/document.py 2014-03-10 08:54:20 +0000
3+++ document/document.py 2014-04-07 08:42:22 +0000
4@@ -89,6 +89,11 @@
5 if not ids:
6 return 0 if count else []
7
8+ # Work with a set, as list.remove() is prohibitive for large lists of documents
9+ # (takes 20+ seconds on a db with 100k docs during search_count()!)
10+ orig_ids = ids
11+ ids = set(ids)
12+
13 # Filter out documents that are in directories that the user is not allowed to read.
14 # Must use pure SQL to avoid access rules exceptions (we want to remove the records,
15 # not fail), and the records have been filtered in parent's search() anyway.
16@@ -108,7 +113,8 @@
17 for parent_id in visible_parent_ids:
18 ids.extend(parents[parent_id])
19
20- return len(ids) if count else ids
21+ result = [id for id in orig_ids if id in ids]
22+ return len(result) if count else result
23
24 def copy(self, cr, uid, id, default=None, context=None):
25 if not default: