From b8e585bb602b00a2ca92e134d9fbe9841bc2fdde Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 23 Apr 2020 12:10:55 +0200 Subject: [PATCH] Optimization --- app/src/main/java/eu/faircode/email/DaoFolder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java index 811da86a6a..1de6f83828 100644 --- a/app/src/main/java/eu/faircode/email/DaoFolder.java +++ b/app/src/main/java/eu/faircode/email/DaoFolder.java @@ -38,16 +38,18 @@ public interface DaoFolder { ", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" + ", account.name AS accountName, account.state AS accountState" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + - ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + - ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + - ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + + ", COUNT(DISTINCT message.id) AS messages" + + ", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" + + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + " FROM folder" + " LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN message ON message.folder = folder.id" + " LEFT JOIN rule ON rule.folder = folder.id" + " LEFT JOIN operation ON operation.folder = folder.id" + - " WHERE folder.account = :account AND account.synchronize" + + " WHERE folder.account = :account" + + " AND account.synchronize" + + " AND NOT message.ui_hide" + " GROUP BY folder.id") List getFoldersEx(long account);