Switched "library.tree" to use "media_children" index
This commit is contained in:
@@ -80,18 +80,12 @@ class Library(LibraryBase):
|
|||||||
result = media
|
result = media
|
||||||
|
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
items = db.get_many('media_children', media['_id'], with_doc = True)
|
||||||
# TODO this probably should be using an index?
|
|
||||||
items = [
|
|
||||||
item['doc']
|
|
||||||
for item in db.all('media', with_doc = True)
|
|
||||||
if item['doc'].get('parent_id') == media['_id']
|
|
||||||
]
|
|
||||||
|
|
||||||
keys = []
|
keys = []
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
key = item['type'] + 's'
|
key = item['doc']['type'] + 's'
|
||||||
|
|
||||||
if key not in result:
|
if key not in result:
|
||||||
result[key] = {}
|
result[key] = {}
|
||||||
@@ -99,7 +93,7 @@ class Library(LibraryBase):
|
|||||||
if key not in keys:
|
if key not in keys:
|
||||||
keys.append(key)
|
keys.append(key)
|
||||||
|
|
||||||
result[key][item['_id']] = fireEvent('library.tree', item, single = True)
|
result[key][item['_id']] = fireEvent('library.tree', item['doc'], single = True)
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
result[key] = result[key].values()
|
result[key] = result[key].values()
|
||||||
|
|||||||
Reference in New Issue
Block a user