Force expire database objects
This commit is contained in:
1 parent
899868f51e
commit
13df35462b
4 files changed
+20
-13
No files matched your search
@@ -133,6 +133,7 @@ class Dashboard(Plugin):
|
|||||||
if len(movies) >= limit:
|
if len(movies) >= limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
'empty': len(movies) == 0,
|
'empty': len(movies) == 0,
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ class LibraryPlugin(Plugin):
|
|||||||
addEvent('library.update', self.update)
|
addEvent('library.update', self.update)
|
||||||
addEvent('library.update_release_date', self.updateReleaseDate)
|
addEvent('library.update_release_date', self.updateReleaseDate)
|
||||||
|
|
||||||
|
|
||||||
def add(self, attrs = {}, update_after = True):
|
def add(self, attrs = {}, update_after = True):
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
@@ -53,6 +52,7 @@ class LibraryPlugin(Plugin):
|
|||||||
|
|
||||||
library_dict = l.to_dict(self.default_dict)
|
library_dict = l.to_dict(self.default_dict)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return library_dict
|
return library_dict
|
||||||
|
|
||||||
def update(self, identifier, default_title = '', force = False):
|
def update(self, identifier, default_title = '', force = False):
|
||||||
@@ -132,6 +132,7 @@ class LibraryPlugin(Plugin):
|
|||||||
|
|
||||||
library_dict = library.to_dict(self.default_dict)
|
library_dict = library.to_dict(self.default_dict)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return library_dict
|
return library_dict
|
||||||
|
|
||||||
def updateReleaseDate(self, identifier):
|
def updateReleaseDate(self, identifier):
|
||||||
@@ -150,6 +151,7 @@ class LibraryPlugin(Plugin):
|
|||||||
library.info = mergeDicts(library.info, {'release_date': dates })
|
library.info = mergeDicts(library.info, {'release_date': dates })
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return dates
|
return dates
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -118,12 +118,13 @@ class MoviePlugin(Plugin):
|
|||||||
.filter(Movie.status_id == done_status.get('id'), Movie.last_edit < (now - week)) \
|
.filter(Movie.status_id == done_status.get('id'), Movie.last_edit < (now - week)) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
#
|
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
for rel in movie.releases:
|
for rel in movie.releases:
|
||||||
if rel.status_id in [available_status.get('id'), snatched_status.get('id')]:
|
if rel.status_id in [available_status.get('id'), snatched_status.get('id')]:
|
||||||
fireEvent('release.delete', id = rel.id, single = True)
|
fireEvent('release.delete', id = rel.id, single = True)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
|
|
||||||
def getView(self):
|
def getView(self):
|
||||||
|
|
||||||
movie_id = getParam('id')
|
movie_id = getParam('id')
|
||||||
@@ -149,6 +150,7 @@ class MoviePlugin(Plugin):
|
|||||||
if m:
|
if m:
|
||||||
results = m.to_dict(self.default_dict)
|
results = m.to_dict(self.default_dict)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def list(self, status = None, release_status = None, limit_offset = None, starts_with = None, search = None, order = None):
|
def list(self, status = None, release_status = None, limit_offset = None, starts_with = None, search = None, order = None):
|
||||||
@@ -216,15 +218,14 @@ class MoviePlugin(Plugin):
|
|||||||
results = q2.all()
|
results = q2.all()
|
||||||
movies = []
|
movies = []
|
||||||
for movie in results:
|
for movie in results:
|
||||||
temp = movie.to_dict({
|
movies.append(movie.to_dict({
|
||||||
'profile': {'types': {}},
|
'profile': {'types': {}},
|
||||||
'releases': {'files':{}, 'info': {}},
|
'releases': {'files':{}, 'info': {}},
|
||||||
'library': {'titles': {}, 'files':{}},
|
'library': {'titles': {}, 'files':{}},
|
||||||
'files': {},
|
'files': {},
|
||||||
})
|
}))
|
||||||
movies.append(temp)
|
|
||||||
|
|
||||||
#db.close()
|
db.expire_all()
|
||||||
return (total_count, movies)
|
return (total_count, movies)
|
||||||
|
|
||||||
def availableChars(self, status = None, release_status = None):
|
def availableChars(self, status = None, release_status = None):
|
||||||
@@ -259,7 +260,7 @@ class MoviePlugin(Plugin):
|
|||||||
if char not in chars:
|
if char not in chars:
|
||||||
chars += str(char)
|
chars += str(char)
|
||||||
|
|
||||||
#db.close()
|
db.expire_all()
|
||||||
return ''.join(sorted(chars, key = str.lower))
|
return ''.join(sorted(chars, key = str.lower))
|
||||||
|
|
||||||
def listView(self):
|
def listView(self):
|
||||||
@@ -318,8 +319,7 @@ class MoviePlugin(Plugin):
|
|||||||
fireEvent('notify.frontend', type = 'movie.busy.%s' % id, data = True)
|
fireEvent('notify.frontend', type = 'movie.busy.%s' % id, data = True)
|
||||||
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True, on_complete = self.createOnComplete(id))
|
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True, on_complete = self.createOnComplete(id))
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
#db.close()
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
})
|
})
|
||||||
@@ -428,7 +428,7 @@ class MoviePlugin(Plugin):
|
|||||||
if added:
|
if added:
|
||||||
fireEvent('notify.frontend', type = 'movie.added', data = movie_dict, message = 'Successfully added "%s" to your wanted list.' % params.get('title', ''))
|
fireEvent('notify.frontend', type = 'movie.added', data = movie_dict, message = 'Successfully added "%s" to your wanted list.' % params.get('title', ''))
|
||||||
|
|
||||||
#db.close()
|
db.expire_all()
|
||||||
return movie_dict
|
return movie_dict
|
||||||
|
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@ class MoviePlugin(Plugin):
|
|||||||
movie_dict = m.to_dict(self.default_dict)
|
movie_dict = m.to_dict(self.default_dict)
|
||||||
fireEventAsync('searcher.single', movie_dict, on_complete = self.createNotifyFront(movie_id))
|
fireEventAsync('searcher.single', movie_dict, on_complete = self.createNotifyFront(movie_id))
|
||||||
|
|
||||||
#db.close()
|
db.expire_all()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
})
|
})
|
||||||
@@ -540,7 +540,7 @@ class MoviePlugin(Plugin):
|
|||||||
if deleted:
|
if deleted:
|
||||||
fireEvent('notify.frontend', type = 'movie.deleted', data = movie.to_dict())
|
fireEvent('notify.frontend', type = 'movie.deleted', data = movie.to_dict())
|
||||||
|
|
||||||
#db.close()
|
db.expire_all()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def restatus(self, movie_id):
|
def restatus(self, movie_id):
|
||||||
@@ -568,7 +568,6 @@ class MoviePlugin(Plugin):
|
|||||||
m.status_id = active_status.get('id') if move_to_wanted else done_status.get('id')
|
m.status_id = active_status.get('id') if move_to_wanted else done_status.get('id')
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
#db.close()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -578,6 +577,7 @@ class MoviePlugin(Plugin):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
movie = db.query(Movie).filter_by(id = movie_id).first()
|
movie = db.query(Movie).filter_by(id = movie_id).first()
|
||||||
fireEventAsync('searcher.single', movie.to_dict(self.default_dict), on_complete = self.createNotifyFront(movie_id))
|
fireEventAsync('searcher.single', movie.to_dict(self.default_dict), on_complete = self.createNotifyFront(movie_id))
|
||||||
|
db.expire_all()
|
||||||
|
|
||||||
return onComplete
|
return onComplete
|
||||||
|
|
||||||
@@ -588,5 +588,6 @@ class MoviePlugin(Plugin):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
movie = db.query(Movie).filter_by(id = movie_id).first()
|
movie = db.query(Movie).filter_by(id = movie_id).first()
|
||||||
fireEvent('notify.frontend', type = 'movie.update.%s' % movie.id, data = movie.to_dict(self.default_dict))
|
fireEvent('notify.frontend', type = 'movie.update.%s' % movie.id, data = movie.to_dict(self.default_dict))
|
||||||
|
db.expire_all()
|
||||||
|
|
||||||
return notifyFront
|
return notifyFront
|
||||||
@@ -62,6 +62,7 @@ class ProfilePlugin(Plugin):
|
|||||||
for profile in profiles:
|
for profile in profiles:
|
||||||
temp.append(profile.to_dict(self.to_dict))
|
temp.append(profile.to_dict(self.to_dict))
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
@@ -109,6 +110,7 @@ class ProfilePlugin(Plugin):
|
|||||||
default = db.query(Profile).first()
|
default = db.query(Profile).first()
|
||||||
default_dict = default.to_dict(self.to_dict)
|
default_dict = default.to_dict(self.to_dict)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return default_dict
|
return default_dict
|
||||||
|
|
||||||
def saveOrder(self):
|
def saveOrder(self):
|
||||||
@@ -151,6 +153,7 @@ class ProfilePlugin(Plugin):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
message = log.error('Failed deleting Profile: %s', e)
|
message = log.error('Failed deleting Profile: %s', e)
|
||||||
|
|
||||||
|
db.expire_all()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': success,
|
'success': success,
|
||||||
'message': message
|
'message': message
|
||||||
|
|||||||
Reference in new issue
Block a user