]> Some of my projects - localmylist.git/commitdiff
Order by episode type ordering as well as epno in OpenFiledata methods.
authorAPTX <marek321@gmail.com>
Sun, 12 May 2013 12:35:06 +0000 (14:35 +0200)
committerAPTX <marek321@gmail.com>
Sun, 12 May 2013 12:35:06 +0000 (14:35 +0200)
localmylist/database.cpp

index 7b0d88cb40ccead40e1b9ec3ea5cc5638bcd6cc3..a2f3ba63b60b78791f61fdc254b6da9f03680f2d 100644 (file)
@@ -94,6 +94,7 @@ OpenFileData Database::firstUnwatchedByExactTitle(const QString &title)
        "       LEFT JOIN anime a ON f.aid = a.aid "
        "       LEFT JOIN anime_title at ON f.aid = at.aid "
        "       LEFT JOIN episode e ON f.eid = e.eid "
+       "       LEFT JOIN episode_type et ON et.type = e.type "
        "       LEFT JOIN file_location fl ON fl.fid = f.fid "
        "       WHERE f.my_watched IS NULL "
        "               AND lower(at.title) = lower(:title) "
@@ -104,7 +105,7 @@ OpenFileData Database::firstUnwatchedByExactTitle(const QString &title)
        "                       SELECT 1 FROM file f "
        "                               JOIN file_episode_rel fer ON fer.eid = e.eid AND f.fid = fer.fid "
        "                               WHERE my_watched IS NOT NULL) "
-       "ORDER BY epno ASC, pixels DESC, f.version DESC ");
+       "ORDER BY et.ordering ASC, epno ASC, pixels DESC, f.version DESC ");
        q.bindValue(":title", title);
 
        return readOpenFileData(q);
@@ -126,6 +127,7 @@ OpenFileData Database::firstUnwatchedByTitle(const QString &title)
        "       LEFT JOIN anime a ON f.aid = a.aid "
        "       LEFT JOIN anime_title at ON f.aid = at.aid "
        "       LEFT JOIN episode e ON f.eid = e.eid "
+       "       LEFT JOIN episode_type et ON et.type = e.type "
        "       LEFT JOIN file_location fl ON fl.fid = f.fid "
        "       WHERE f.my_watched IS NULL "
        "               AND at.title ILIKE :fuzzyTitle "
@@ -136,7 +138,7 @@ OpenFileData Database::firstUnwatchedByTitle(const QString &title)
        "                       SELECT 1 FROM file f "
        "                               JOIN file_episode_rel fer ON fer.eid = e.eid AND f.fid = fer.fid "
        "                               WHERE my_watched IS NOT NULL) "
-       "ORDER BY epno ASC, pixels DESC, f.version DESC ");
+       "ORDER BY et.ordering ASC, epno ASC, pixels DESC, f.version DESC ");
        q.bindValue(":fuzzyTitle", "%" + title + "%");
 
        ofd = readOpenFileData(q);
@@ -152,12 +154,13 @@ OpenFileData Database::firstUnwatchedByAid(int aid)
        "       FROM file f "
        "       LEFT JOIN anime a ON f.aid = a.aid "
        "       LEFT JOIN episode e ON f.eid = e.eid "
+       "       LEFT JOIN episode_type et ON et.type = e.type "
        "       LEFT JOIN file_location fl ON fl.fid = f.fid "
        "       WHERE f.my_watched IS NULL "
        "               AND f.aid = :aid "
        "               AND fl.path IS NOT NULL "
        "               AND NOT EXISTS (SELECT 1 FROM file WHERE eid = e.eid AND my_watched IS NOT NULL LIMIT 1) "
-       "ORDER BY e.epno ASC, pixels DESC, f.version DESC ");
+       "ORDER BY et.ordering ASC, e.epno ASC, pixels DESC, f.version DESC ");
        q.bindValue(":aid", aid);
 
        return readOpenFileData(q);