diff --git a/public/js/wn/dom.js b/public/js/wn/dom.js index 6e79df4acc..b0f745520d 100644 --- a/public/js/wn/dom.js +++ b/public/js/wn/dom.js @@ -133,14 +133,14 @@ wn.get_shade = function(color, factor) { var get_int = function(hex) { return parseInt(hex,16); } - return get_hex(get_int(color.substr(0,2)) * factor) - + get_hex(get_int(color.substr(2,2)) * factor) - + get_hex(get_int(color.substr(4,2)) * factor) + return get_hex(get_int(color.substr(0,2)) + factor) + + get_hex(get_int(color.substr(2,2)) + factor) + + get_hex(get_int(color.substr(4,2)) + factor) } wn.get_gradient_css = function(col) { - var col1 = wn.get_shade(col, 1.05); - var col2 = wn.get_shade(col, 0.95); + var col1 = wn.get_shade(col, 10); + var col2 = wn.get_shade(col, -10); return "\nbackground-color: " + col + " !important;" +"\nbackground: -moz-linear-gradient(top, #"+col1+" 0%, #"+col2+" 99%) !important;" +"\nbackground:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#"+col1+"), color-stop(99%,#"+col2+")) !important;" diff --git a/webnotes/sessions.py b/webnotes/sessions.py index c6b5fff527..2b122a78c4 100644 --- a/webnotes/sessions.py +++ b/webnotes/sessions.py @@ -208,12 +208,24 @@ class Session: """extend session expiry""" self.data['data']['last_updated'] = webnotes.utils.now() - if webnotes.session['user'] != 'Guest' and (self.time_diff and \ - self.time_diff > 1800): + # update session in db + time_diff = None + last_updated = webnotes.cache().get_value("last_db_session_update:" + self.sid) + + if last_updated: + time_diff = webnotes.utils.time_diff_in_seconds(webnotes.utils.now(), + last_updated) + + if webnotes.session['user'] != 'Guest' and \ + ((not time_diff) or (time_diff > 1800)): # database persistence is secondary, don't update it too often webnotes.conn.sql("""update tabSessions set sessiondata=%s, lastupdate=NOW() where sid=%s""" , (str(self.data['data']), self.data['sid'])) + + # update timestamp of update + webnotes.cache().set_value("last_db_session_update:" + self.sid, + webnotes.utils.now()) if webnotes.request.cmd!="webnotes.sessions.clear": webnotes.cache().set_value("session:" + self.sid, self.data)