From f2b0d3f80bcd41f062ee3a68e9de4b959c5ec719 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Sat, 26 Jul 2014 13:54:55 +1200 Subject: [PATCH] Switched "library.tree" to use "media_children" index --- couchpotato/core/media/_base/library/main.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/media/_base/library/main.py b/couchpotato/core/media/_base/library/main.py index d20342f2..c0e4464b 100755 --- a/couchpotato/core/media/_base/library/main.py +++ b/couchpotato/core/media/_base/library/main.py @@ -80,18 +80,12 @@ class Library(LibraryBase): result = media db = get_db() - - # 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'] - ] + items = db.get_many('media_children', media['_id'], with_doc = True) keys = [] for item in items: - key = item['type'] + 's' + key = item['doc']['type'] + 's' if key not in result: result[key] = {} @@ -99,7 +93,7 @@ class Library(LibraryBase): if key not in keys: 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: result[key] = result[key].values()