From f48a0c4a8bda49c229d89dffa03855438d667430 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 27 Nov 2012 15:47:24 +0100 Subject: [PATCH] put global variables for fine tuning bzr revid: nicolas.vanhoren@openerp.com-20121127144724-8b9tc0ix6xplpojp --- addons/web_im/im.py | 6 ++++-- addons/web_im/static/src/js/im.js | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/web_im/im.py b/addons/web_im/im.py index 2ecc1d23c01..a16203947f1 100644 --- a/addons/web_im/im.py +++ b/addons/web_im/im.py @@ -24,6 +24,8 @@ import openerp.tools.config import openerp.modules.registry from osv import osv, fields +WATCHER_TIMER = 60 +POLL_TIMER = 30 if openerp.tools.config.options["gevent"]: import gevent @@ -59,7 +61,7 @@ if openerp.tools.config.options["gevent"]: try: c.execute("listen received_message;") c.commit(); - if select.select([conn], [], [], 60) == ([],[],[]): + if select.select([conn], [], [], WATCHER_TIMER) == ([],[],[]): pass else: conn.poll() @@ -99,7 +101,7 @@ class ImportController(openerp.addons.web.http.Controller): last = res["last"] num += 1 print "waiting" - Watcher.get_watcher(res["dbname"]).stop(30) + Watcher.get_watcher(res["dbname"]).stop(POLL_TIMER) class im_message(osv.osv): diff --git a/addons/web_im/static/src/js/im.js b/addons/web_im/static/src/js/im.js index 123ec4d1c0b..92eab8d54ff 100644 --- a/addons/web_im/static/src/js/im.js +++ b/addons/web_im/static/src/js/im.js @@ -1,6 +1,9 @@ openerp.web_im = function(instance) { + var USERS_LIMIT = 20; + var ERROR_DELAY = 5000; + instance.web.UserMenu.include({ do_update: function(){ var self = this; @@ -59,7 +62,7 @@ openerp.web_im = function(instance) { } var users = new instance.web.Model("res.users"); var self = this; - return users.query(["name"]).filter([["name", "ilike", this.$(".oe_im_input").val()]]).limit(20).all().then(function(result) { + return users.query(["name"]).filter([["name", "ilike", this.$(".oe_im_input").val()]]).limit(USERS_LIMIT).all().then(function(result) { self.$(".oe_im_input").val(""); _.each(self.users, function(user) { user.destroy(); @@ -105,7 +108,7 @@ openerp.web_im = function(instance) { self.poll(); }, function(unused, e) { e.preventDefault(); - setTimeout(_.bind(self.poll, self), 5000); + setTimeout(_.bind(self.poll, self), ERROR_DELAY); }); }, activate_user: function(user_rec) {