Move with_status out of releases

This commit is contained in:
Ruud
2014-03-21 16:21:49 +01:00
parent b4a3ac8081
commit b63f7b7e5d
4 changed files with 14 additions and 11 deletions
@@ -22,14 +22,6 @@ class ReleaseIndex(TreeBasedIndex):
for release in db.get_many('release', media_id, with_doc = True):
yield release['doc']
def run_with_status(self, db, status = [], with_doc = True):
status = list(status if isinstance(status, (list, tuple)) else [status])
for s in status:
for ms in db.get_many('release_status', s, with_doc = with_doc):
yield ms['doc'] if with_doc else ms
class ReleaseStatusIndex(TreeBasedIndex):
_version = 1
+11
View File
@@ -53,6 +53,7 @@ class Release(Plugin):
addEvent('release.delete', self.delete)
addEvent('release.clean', self.clean)
addEvent('release.update_status', self.updateStatus)
addEvent('release.with_status', self.withStatus)
# Clean releases that didn't have activity in the last week
addEvent('app.load', self.cleanDone)
@@ -422,3 +423,13 @@ class Release(Plugin):
log.error('Failed: %s', traceback.format_exc())
return False
def withStatus(self, status, with_doc = True):
db = get_db()
status = list(status if isinstance(status, (list, tuple)) else [status])
for s in status:
for ms in db.get_many('release_status', s, with_doc = with_doc):
yield ms['doc'] if with_doc else ms
+1 -1
View File
@@ -834,7 +834,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
try:
db = get_db()
rels = list(db.run('release', 'with_status', ['snatched', 'seeding', 'missing']))
rels = list(fireEvent('release.with_status', ['snatched', 'seeding', 'missing'], single = True))
if not rels:
#No releases found that need status checking