Merge lp:~dreis-pt/project-service/7.0-fixcounters into lp:~project-core-editors/project-service/trunk

Proposed by Daniel Reis
Status: Needs review
Proposed branch: lp:~dreis-pt/project-service/7.0-fixcounters
Merge into: lp:~project-core-editors/project-service/trunk
Diff against target: 128 lines (+107/-0)
4 files modified
.bzrignore (+1/-0)
project_issue_fixcount/__init__.py (+2/-0)
project_issue_fixcount/__openerp__.py (+35/-0)
project_issue_fixcount/project.py (+69/-0)
To merge this branch: bzr merge lp:~dreis-pt/project-service/7.0-fixcounters
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Information
Stefan Rijnhart (Opener) Pending
Review via email: mp+219558@code.launchpad.net

Description of the change

In v7, Project kanban can take forever to load, due to inefficient implementation of the counters (Issues, Tasks and Documents).
AFAIK it has been fixed in v8, so this is mostly a backport for that work.

To post a comment you must log in.
41. By Daniel Reis

New project_issue_fixcounter module

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Daniel, don't you think this fits best on OCB?

Regards.

review: Needs Information
Revision history for this message
Daniel Reis (dreis-pt) wrote :

I did hesitate on that. Let's ask for Stephan's opinion on it.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I suppose that he said that changes are too deep for OCB, and maybe he's right, but I don't think v7 is going to receive too much changes on this part to produce conflicts.

Let's see what he says.

Regards.

Revision history for this message
Daniel Reis (dreis-pt) wrote :

This project is now hosted on https://github.com/OCA/project-service. Please move your proposal there.
This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

41. By Daniel Reis

New project_issue_fixcounter module

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2012-06-27 14:33:04 +0000
+++ .bzrignore 2014-05-14 16:19:44 +0000
@@ -1,1 +1,2 @@
1*.pyc1*.pyc
2project_issue_fixcount/.ropeproject
23
=== added directory 'project_issue_fixcount'
=== added file 'project_issue_fixcount/__init__.py'
--- project_issue_fixcount/__init__.py 1970-01-01 00:00:00 +0000
+++ project_issue_fixcount/__init__.py 2014-05-14 16:19:44 +0000
@@ -0,0 +1,2 @@
1# -*- coding: utf-8 -*-
2import project
03
=== added file 'project_issue_fixcount/__openerp__.py'
--- project_issue_fixcount/__openerp__.py 1970-01-01 00:00:00 +0000
+++ project_issue_fixcount/__openerp__.py 2014-05-14 16:19:44 +0000
@@ -0,0 +1,35 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2014 Daniel Reis
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20{
21 'name': 'Backport more efficient Project counters',
22 'version': '1.0',
23 "category": "Project Management",
24 'description': """\
25Fix performance issues with v7 Project counters.
26Will probably be unnecessary in v8.
27""",
28 'author': 'Daniel Reis',
29 'website': '',
30 'depends': [
31 'project_issue',
32 ],
33 'data': [],
34 'installable': True,
35}
036
=== added file 'project_issue_fixcount/project.py'
--- project_issue_fixcount/project.py 1970-01-01 00:00:00 +0000
+++ project_issue_fixcount/project.py 2014-05-14 16:19:44 +0000
@@ -0,0 +1,69 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2014 Daniel Reis
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.osv import fields, orm
22
23
24class Project(orm.Model):
25 _inherit = 'project.project'
26
27 def _task_count(self, cr, uid, ids, field_name, arg, context=None):
28 "Backport from v8"
29 res = {}
30 for tasks in self.browse(cr, uid, ids, context):
31 res[tasks.id] = len(tasks.task_ids)
32 return res
33
34 def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
35 "Backport from v8"
36 Issue = self.pool['project.issue']
37 return {
38 project_id: Issue.search_count(
39 cr, uid,
40 [('project_id', '=', project_id),
41 ('stage_id.fold', '=', False)],
42 context=context)
43 for project_id in ids
44 }
45
46 def _get_attached_docs(self, cr, uid, ids, field_name, arg, context):
47 "We don't count documents to improve performance"
48 res = {}
49 # attachment = self.pool.get('ir.attachment')
50 # task = self.pool.get('project.task')
51 for id in ids:
52 # project_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.project'), ('res_id', '=', id)], context=context, count=True)
53 # task_ids = task.search(cr, uid, [('project_id', '=', id)], context=context)
54 # task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context, count=True)
55 res[id] = 0 # (project_attachments or 0) + (task_attachments or 0)
56 return res
57
58 _columns = {
59 'task_count': fields.function(
60 _task_count, type='integer', string="Tasks",),
61 'task_ids': fields.one2many(
62 'project.task', 'project_id',
63 domain=[('stage_id.fold', '=', False)]),
64 'issue_count': fields.function(
65 _issue_count, string='# Issues', type='integer'),
66 'doc_count': fields.function(
67 _get_attached_docs,
68 string="Number of documents attached", type='integer'),
69 }

Subscribers

People subscribed via source and target branches