Move multi-identifier search out of index
This commit is contained in:
1 parent
269d779df7
commit
a818276b6d
2 files changed
+14
-8
No files matched your search
@@ -30,14 +30,6 @@ class MediaIndex(MultiTreeBasedIndex):
|
|||||||
|
|
||||||
return ids, None
|
return ids, None
|
||||||
|
|
||||||
def run_identifiers(self, db, identifiers, with_doc = False):
|
|
||||||
for x in identifiers:
|
|
||||||
try:
|
|
||||||
media = db.get('media', '%s-%s' % (x, identifiers[x]), with_doc = with_doc)
|
|
||||||
return media
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MediaStatusIndex(TreeBasedIndex):
|
class MediaStatusIndex(TreeBasedIndex):
|
||||||
_version = 1
|
_version = 1
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class MediaPlugin(MediaBase):
|
|||||||
|
|
||||||
addEvent('media.get', self.get)
|
addEvent('media.get', self.get)
|
||||||
addEvent('media.with_status', self.withStatus)
|
addEvent('media.with_status', self.withStatus)
|
||||||
|
addEvent('media.with_identifiers', self.withIdentifiers)
|
||||||
addEvent('media.list', self.list)
|
addEvent('media.list', self.list)
|
||||||
addEvent('media.delete', self.delete)
|
addEvent('media.delete', self.delete)
|
||||||
addEvent('media.restatus', self.restatus)
|
addEvent('media.restatus', self.restatus)
|
||||||
@@ -157,6 +158,19 @@ class MediaPlugin(MediaBase):
|
|||||||
for ms in db.get_many('media_status', s, with_doc = with_doc):
|
for ms in db.get_many('media_status', s, with_doc = with_doc):
|
||||||
yield ms['doc'] if with_doc else ms
|
yield ms['doc'] if with_doc else ms
|
||||||
|
|
||||||
|
def withIdentifiers(self, identifiers, with_doc = False):
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
for x in identifiers:
|
||||||
|
try:
|
||||||
|
media = db.get('media', '%s-%s' % (x, identifiers[x]), with_doc = with_doc)
|
||||||
|
return media
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
log.error('No media found with identifiers: %s', identifiers)
|
||||||
|
|
||||||
def list(self, types = None, status = None, release_status = None, status_or = False, limit_offset = None, starts_with = None, search = None):
|
def list(self, types = None, status = None, release_status = None, status_or = False, limit_offset = None, starts_with = None, search = None):
|
||||||
|
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|||||||
Reference in new issue
Block a user