[IMP] gamification: performance improvement on the goal computation
Removing the inheritance to mail.thread will avoid posting message at creation and other tracking mechanism at each write. Updating a challenge with a large number of users will be significantly faster. bzr revid: mat@openerp.com-20140506093716-xvpe1n2ase2zix0v
This commit is contained in:
parent
ae6a0fcb73
commit
bde55baaa9
|
@ -355,10 +355,13 @@ class gamification_challenge(osv.Model):
|
|||
if write_op:
|
||||
self.write(cr, uid, [challenge.id], {'user_ids': write_op}, context=context)
|
||||
|
||||
if to_remove_ids:
|
||||
self.message_unsubscribe_users(cr, uid, [challenge.id], to_remove_ids, context=None)
|
||||
if to_add_ids:
|
||||
self.message_subscribe_users(cr, uid, [challenge.id], to_add_ids, context=context)
|
||||
if challenge.report_message_frequency != 'never':
|
||||
if to_remove_ids:
|
||||
self.message_unsubscribe_users(cr, uid, [challenge.id], to_remove_ids, context=context)
|
||||
if to_add_ids:
|
||||
self.message_subscribe_users(cr, uid, [challenge.id], to_add_ids, context=context)
|
||||
else:
|
||||
self.message_unsubscribe_users(cr, uid, [challenge.id], old_user_ids, context=context)
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -138,7 +138,6 @@ class gamification_goal(osv.Model):
|
|||
|
||||
_name = 'gamification.goal'
|
||||
_description = 'Gamification goal instance'
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
def _get_completion(self, cr, uid, ids, field_name, arg, context=None):
|
||||
"""Return the percentage of completeness of the goal, between 0 and 100"""
|
||||
|
@ -226,8 +225,7 @@ class gamification_goal(osv.Model):
|
|||
temp_obj = self.pool.get('email.template')
|
||||
template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_goal_reminder', context)
|
||||
body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.goal', goal.id, context=context)
|
||||
|
||||
self.message_post(cr, uid, goal.id, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment')
|
||||
self.pool['mail.thread'].message_post(cr, uid, 0, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment')
|
||||
return {'to_update': True}
|
||||
return {}
|
||||
|
||||
|
|
|
@ -86,10 +86,6 @@
|
|||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue