From: APTX Date: Sun, 21 Apr 2013 16:57:54 +0000 (+0200) Subject: Prefer the file with the highest resolution in firstUnwatched* methods. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=87ee453d2aa2c3f2f952f2b20f229fa06f04cfe1;p=localmylist.git Prefer the file with the highest resolution in firstUnwatched* methods. --- diff --git a/localmylist/database.cpp b/localmylist/database.cpp index aba2447..72b771b 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -88,7 +88,9 @@ return false; OpenFileData Database::firstUnwatchedByExactTitle(const QString &title) { QSqlQuery &q = prepare( - "SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id FROM file f " + "SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id, " + " CASE WHEN split_part(f.resolution, 'x', 1) = '' OR split_part(f.resolution, 'x', 2) = '' THEN 0 ELSE split_part(f.resolution, 'x', 1)::int * split_part(f.resolution, 'x', 2)::int END pixels " + " FROM file f " " 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 " @@ -102,7 +104,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 "); + "ORDER BY epno ASC, pixels DESC "); q.bindValue(":title", title); return readOpenFileData(q); @@ -118,7 +120,9 @@ OpenFileData Database::firstUnwatchedByTitle(const QString &title) return ofd; QSqlQuery &q = prepare( - "SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id FROM file f " + "SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id, " + " CASE WHEN split_part(f.resolution, 'x', 1) = '' OR split_part(f.resolution, 'x', 2) = '' THEN 0 ELSE split_part(f.resolution, 'x', 1)::int * split_part(f.resolution, 'x', 2)::int END pixels " + " FROM file f " " 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 " @@ -132,7 +136,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 "); + "ORDER BY epno ASC, pixels DESC "); q.bindValue(":fuzzyTitle", "%" + title + "%"); ofd = readOpenFileData(q);