Optimized listing of messages

pull/214/head
M66B 1 year ago
parent d0da94dca9
commit cda1580241

@ -75,15 +75,14 @@ public interface DaoMessage {
" OR (NOT :found AND :type IS NULL AND folder.unified)" + " OR (NOT :found AND :type IS NULL AND folder.unified)" +
" OR (NOT :found AND folder.type = :type)" + " OR (NOT :found AND folder.type = :type)" +
" THEN message.received ELSE 0 END) AS dummy" + " THEN message.received ELSE 0 END) AS dummy" +
" FROM (SELECT * FROM message" + " FROM message" +
" WHERE message.thread IN" +
" (SELECT DISTINCT mm.thread FROM folder ff" + // group_concat
" JOIN message mm ON mm.folder = ff.id" + " JOIN message AS mm ON mm.thread = message.thread" +
" WHERE ((:found AND mm.ui_found)" + " AND (NOT :found OR mm.ui_found) AND (NOT mm.ui_hide OR :debug)" +
" OR (NOT :found AND :type IS NULL AND ff.unified)" + " JOIN folder AS ff ON ff.id = mm.folder" +
" OR (NOT :found AND :type IS NOT NULL AND ff.type = :type))" + " AND (:found OR (:type IS NULL AND ff.unified) OR (:type IS NOT NULL AND ff.type = :type))" +
" AND (NOT mm.ui_hide OR :debug))" +
" ORDER BY received DESC) AS message" + // group_concat
" JOIN account_view AS account ON account.id = message.account" + " JOIN account_view AS account ON account.id = message.account" +
" LEFT JOIN identity_view AS identity ON identity.id = message.identity" + " LEFT JOIN identity_view AS identity ON identity.id = message.identity" +
" JOIN folder_view AS folder ON folder.id = message.folder" + " JOIN folder_view AS folder ON folder.id = message.folder" +
@ -101,6 +100,7 @@ public interface DaoMessage {
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_drafts + ")" + " AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_drafts + ")" +
" AND (NOT :filter_deleted OR NOT message.ui_deleted)" + " AND (NOT :filter_deleted OR NOT message.ui_deleted)" +
" AND (:filter_language IS NULL OR SUM(message.language = :filter_language) > 0)" + " AND (:filter_language IS NULL OR SUM(message.language = :filter_language) > 0)" +
" ORDER BY CASE WHEN :found THEN 0 ELSE -IFNULL(message.importance, 1) END" + " ORDER BY CASE WHEN :found THEN 0 ELSE -IFNULL(message.importance, 1) END" +
", CASE WHEN :group_category THEN account.category ELSE '' END COLLATE NOCASE" + ", CASE WHEN :group_category THEN account.category ELSE '' END COLLATE NOCASE" +
", CASE" + ", CASE" +
@ -114,7 +114,8 @@ public interface DaoMessage {
" WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" ELSE 0" + " ELSE 0" +
" END" + " END" +
", CASE WHEN :ascending THEN message.received ELSE -message.received END") ", CASE WHEN :ascending THEN message.received ELSE -message.received END" +
", mm.received")
DataSource.Factory<Integer, TupleMessageEx> pagedUnified( DataSource.Factory<Integer, TupleMessageEx> pagedUnified(
String type, String type,
boolean threading, boolean group_category, boolean threading, boolean group_category,
@ -153,13 +154,13 @@ public interface DaoMessage {
" (:found AND folder.type <> '" + EntityFolder.ARCHIVE + "' AND NOT (" + is_outgoing + "))" + " (:found AND folder.type <> '" + EntityFolder.ARCHIVE + "' AND NOT (" + is_outgoing + "))" +
" OR (NOT :found AND folder.id = :folder)" + " OR (NOT :found AND folder.id = :folder)" +
" THEN message.received ELSE 0 END) AS dummy" + " THEN message.received ELSE 0 END) AS dummy" +
" FROM (SELECT * FROM message" + " FROM message" +
" WHERE message.thread IN" +
" (SELECT DISTINCT mm.thread FROM message mm" + // group_concat
" WHERE mm.folder = :folder" + " JOIN message AS mm ON mm.thread = message.thread" +
" AND (NOT mm.ui_hide OR :debug)" + " AND (NOT :found OR mm.ui_found) AND (NOT mm.ui_hide OR :debug)" +
" AND (NOT :found OR mm.ui_found))" + " AND message.folder = :folder" +
" ORDER BY received DESC) AS message" + // group_concat
" JOIN account_view AS account ON account.id = message.account" + " JOIN account_view AS account ON account.id = message.account" +
" LEFT JOIN identity_view AS identity ON identity.id = message.identity" + " LEFT JOIN identity_view AS identity ON identity.id = message.identity" +
" JOIN folder_view AS folder ON folder.id = message.folder" + " JOIN folder_view AS folder ON folder.id = message.folder" +
@ -188,7 +189,8 @@ public interface DaoMessage {
" WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" ELSE 0" + " ELSE 0" +
" END" + " END" +
", CASE WHEN :ascending THEN message.received ELSE -message.received END") ", CASE WHEN :ascending THEN message.received ELSE -message.received END" +
", mm.received")
DataSource.Factory<Integer, TupleMessageEx> pagedFolder( DataSource.Factory<Integer, TupleMessageEx> pagedFolder(
long folder, boolean threading, long folder, boolean threading,
String sort, boolean ascending, String sort, boolean ascending,

Loading…
Cancel
Save