Optimize dashboard.soon with joins
This commit is contained in:
@@ -6,6 +6,7 @@ from couchpotato.core.helpers.variable import splitString, tryInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Movie
|
||||
from sqlalchemy.orm import joinedload_all
|
||||
from sqlalchemy.sql.expression import or_
|
||||
import random
|
||||
import time
|
||||
@@ -75,6 +76,14 @@ class Dashboard(Plugin):
|
||||
# Get all active movies
|
||||
q = db.query(Movie) \
|
||||
.join(Movie.profile, Movie.library) \
|
||||
.options(joinedload_all('releases')) \
|
||||
.options(joinedload_all('releases.files')) \
|
||||
.options(joinedload_all('releases.info')) \
|
||||
.options(joinedload_all('profile.types')) \
|
||||
.options(joinedload_all('library.titles')) \
|
||||
.options(joinedload_all('library.files')) \
|
||||
.options(joinedload_all('status')) \
|
||||
.options(joinedload_all('files')) \
|
||||
.filter(or_(*[Movie.status.has(identifier = s) for s in ['active']])) \
|
||||
.group_by(Movie.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user