micro optimization
This commit is contained in:
parent
8c23d73bd3
commit
ebc0f28799
1 changed files with 6 additions and 3 deletions
|
@ -127,14 +127,15 @@ class Item(db.Model):
|
||||||
state.db.session.execute(q)
|
state.db.session.execute(q)
|
||||||
|
|
||||||
def json(self, keys=None):
|
def json(self, keys=None):
|
||||||
j = {}
|
j = {}
|
||||||
j['id'] = self.id
|
j['id'] = self.id
|
||||||
j['created'] = self.created
|
j['created'] = self.created
|
||||||
j['modified'] = self.modified
|
j['modified'] = self.modified
|
||||||
j['timesaccessed'] = self.timesaccessed
|
j['timesaccessed'] = self.timesaccessed
|
||||||
j['accessed'] = self.accessed
|
j['accessed'] = self.accessed
|
||||||
j['added'] = self.added
|
j['added'] = self.added
|
||||||
if state.downloads and not state.shutdown:
|
if (not keys or 'transferadded' in keys or 'transferprogress' in keys) \
|
||||||
|
and state.downloads and not state.shutdown:
|
||||||
t = state.downloads.transfers.get(self.id)
|
t = state.downloads.transfers.get(self.id)
|
||||||
if t:
|
if t:
|
||||||
j['transferadded'] = t['added']
|
j['transferadded'] = t['added']
|
||||||
|
@ -149,7 +150,9 @@ class Item(db.Model):
|
||||||
j[key] = self.info[key]
|
j[key] = self.info[key]
|
||||||
|
|
||||||
if self.meta:
|
if self.meta:
|
||||||
j.update(self.meta)
|
for key in self.meta:
|
||||||
|
if not keys or key in keys:
|
||||||
|
j[key] = self.meta[key]
|
||||||
|
|
||||||
for key in self.id_keys:
|
for key in self.id_keys:
|
||||||
if key not in self.meta and key in j:
|
if key not in self.meta and key in j:
|
||||||
|
|
Loading…
Reference in a new issue