Browse Source

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

pull/2133/head
Ruud 12 years ago
parent
commit
226cf6fc38
  1. 2
      couchpotato/core/media/movie/_base/main.py
  2. 6
      couchpotato/core/plugins/dashboard/main.py

2
couchpotato/core/media/movie/_base/main.py

@ -213,6 +213,8 @@ class MovieBase(MovieTypeBase):
q = q.filter(or_(*filter_or))
total_count = q.count()
if total_count == 0:
return 0, []
if order == 'release_order':
q = q.order_by(desc(Release.last_edit))

6
couchpotato/core/plugins/dashboard/main.py

@ -61,6 +61,9 @@ class Dashboard(Plugin):
.order_by(asc(LibraryTitle.simple_title))
active = q.all()
movies = []
if len(active) > 0:
# Do the shuffle
if random:
@ -92,6 +95,8 @@ class Dashboard(Plugin):
if len(movie_ids) >= limit:
break
if len(movie_ids) > 0:
# Get all movie information
movies_raw = db.query(Movie) \
.options(joinedload_all('library.titles')) \
@ -105,7 +110,6 @@ class Dashboard(Plugin):
for movie in movies_raw:
movie_dict[movie.id] = movie
movies = []
for movie_id in movie_ids:
movies.append(movie_dict[movie_id].to_dict({
'library': {'titles': {}, 'files':{}},

Loading…
Cancel
Save