Get unexposed message count

pull/214/head
M66B 6 months ago
parent 947ae77df3
commit c986de943d

@ -72,6 +72,16 @@ public interface DaoAccount {
" AND folder.count_unread" +
" AND NOT ui_seen" +
" AND NOT ui_hide) AS unseen" +
", (SELECT COUNT(DISTINCT" +
" CASE WHEN NOT message.hash IS NULL THEN message.hash" +
" WHEN NOT message.msgid IS NULL THEN message.msgid" +
" ELSE message.id END)" +
" FROM message" +
" JOIN folder ON folder.id = message.folder" +
" WHERE message.account = account.id" +
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
" AND message.received > folder.last_view" +
" AND NOT ui_hide) AS unexposed" +
" FROM account" +
" LEFT JOIN folder AS drafts ON drafts.account = account.id AND drafts.type = '" + EntityFolder.DRAFTS + "'" +
" LEFT JOIN folder AS sent ON sent.account = account.id AND sent.type = '" + EntityFolder.SENT + "'" +
@ -98,6 +108,14 @@ public interface DaoAccount {
" WHERE message.folder = folder.id" +
" AND NOT ui_seen" +
" AND NOT ui_hide) AS unseen" +
", (SELECT COUNT(DISTINCT" +
" CASE WHEN NOT message.hash IS NULL THEN message.hash" +
" WHEN NOT message.msgid IS NULL THEN message.msgid" +
" ELSE message.id END)" +
" FROM message" +
" WHERE message.folder = folder.id" +
" AND message.received > folder.last_view" +
" AND NOT ui_hide) AS unexposed" +
" FROM account" +
" JOIN folder ON folder.account = account.id" +
" LEFT JOIN operation ON operation.folder = folder.id AND operation.state = 'executing'" +

@ -44,6 +44,7 @@ public interface DaoFolder {
", 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 message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" +
", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" +
@ -84,6 +85,7 @@ public interface DaoFolder {
", 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 CASE WHEN message.received > folder.last_view AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unexposed" +
", COUNT(DISTINCT CASE WHEN message.ui_flagged AND NOT message.ui_hide THEN message.id ELSE NULL END) AS flagged" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" +
@ -108,6 +110,7 @@ public interface DaoFolder {
", 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 message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" +
", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" +
@ -141,6 +144,7 @@ public interface DaoFolder {
", 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 message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" +
", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" +
@ -190,6 +194,7 @@ public interface DaoFolder {
", COUNT(DISTINCT folder.id) AS folders" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN NOT message.ui_seen THEN 1 ELSE 0 END) AS unseen" +
", SUM(CASE WHEN message.received > folder.last_view THEN 1 ELSE 0 END) AS unexposed" +
", CASE WHEN folder.account IS NULL THEN folder.sync_state ELSE NULL END AS sync_state" +
", folder.color, COUNT (DISTINCT folder.color) AS colorCount" +
" FROM folder" +

@ -46,6 +46,7 @@ public class TupleAccountFolder extends EntityAccount {
public int executing;
public int messages;
public int unseen;
public int unexposed;
public String getName(Context context) {
if (folderName == null)

@ -49,6 +49,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
public int messages;
public int content;
public int unseen;
public int unexposed;
public int flagged;
public int executing;
@ -84,6 +85,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
this.messages == other.messages &&
this.content == other.content &&
this.unseen == other.unseen &&
this.unexposed == other.unexposed &&
this.flagged == other.flagged &&
this.executing == other.executing);
} else

@ -27,6 +27,7 @@ public class TupleFolderUnified {
public int folders;
public int messages;
public int unseen;
public int unexposed;
public String sync_state;
public Integer color;
public int colorCount;

Loading…
Cancel
Save