Make sure to not query db when there aren't any ids

This commit is contained in:
Ruud committed 2013-09-06 22:45:37 +02:00
1 parent 203a52bfd1
commit 226cf6fc38
2 files changed
+7 -1

No files matched your search

@@ -213,6 +213,8 @@ class MovieBase(MovieTypeBase):
q = q.filter(or_(*filter_or)) q = q.filter(or_(*filter_or))
total_count = q.count() total_count = q.count()
if total_count == 0:
return 0, []
if order == 'release_order': if order == 'release_order':
q = q.order_by(desc(Release.last_edit)) q = q.order_by(desc(Release.last_edit))
+5 -1
View File
@@ -61,6 +61,9 @@ class Dashboard(Plugin):
.order_by(asc(LibraryTitle.simple_title)) .order_by(asc(LibraryTitle.simple_title))
active = q.all() active = q.all()
movies = []
if len(active) > 0:
# Do the shuffle # Do the shuffle
if random: if random:
@@ -92,6 +95,8 @@ class Dashboard(Plugin):
if len(movie_ids) >= limit: if len(movie_ids) >= limit:
break break
if len(movie_ids) > 0:
# Get all movie information # Get all movie information
movies_raw = db.query(Movie) \ movies_raw = db.query(Movie) \
.options(joinedload_all('library.titles')) \ .options(joinedload_all('library.titles')) \
@@ -105,7 +110,6 @@ class Dashboard(Plugin):
for movie in movies_raw: for movie in movies_raw:
movie_dict[movie.id] = movie movie_dict[movie.id] = movie
movies = []
for movie_id in movie_ids: for movie_id in movie_ids:
movies.append(movie_dict[movie_id].to_dict({ movies.append(movie_dict[movie_id].to_dict({
'library': {'titles': {}, 'files':{}}, 'library': {'titles': {}, 'files':{}},