avoid extra lookup

This commit is contained in:
j 2016-02-25 13:09:59 +05:30
parent 1c2ef33353
commit d7528f634f
2 changed files with 16 additions and 17 deletions

View file

@ -445,15 +445,10 @@ class Nodes(Thread):
else:
self._call(*args)
def cleanup(self):
if not state.shutdown and self._local:
self._local.cleanup()
def pull(self):
if not self._pulling:
self.queue('pull')
def queue(self, *args):
self._q.put(list(args))
@ -493,6 +488,10 @@ class Nodes(Thread):
if send_response:
self._nodes[user_id].send_response()
def pull(self):
if not self._pulling:
self.queue('pull')
def _pull(self):
if state.activity and state.activity.get('activity') == 'import':
return
@ -503,7 +502,7 @@ class Nodes(Thread):
with db.session():
from user.models import User
for u in User.query.filter(User.id!=settings.USER_ID).filter_by(peered=True).all():
users.append(u.json())
users.append(u.json(['id', 'index', 'name']))
users.sort(key=user_sort_key)
for u in users:
if state.shutdown:

View file

@ -86,10 +86,10 @@ class User(db.Model):
if self.pending:
j['pending'] = self.pending
j['peered'] = self.peered
if not keys or 'online' in keys:
j['online'] = self.is_online()
j['nickname'] = self.info.get('nickname')
j['username'] = self.info.get('username')
j['name'] = self.name
if not keys or 'username' in keys or 'contact' in keys:
if self.id == settings.USER_ID:
j['username'] = settings.preferences['username']
j['contact'] = settings.preferences['contact']