Simplify account/operation stats

This commit is contained in:
M66B 2018-12-21 08:59:01 +01:00
parent 099239ca64
commit fa8952404a
1 changed files with 8 additions and 9 deletions

View File

@ -71,16 +71,15 @@ public interface DaoAccount {
LiveData<EntityAccount> liveAccount(long id);
@Query("SELECT" +
" (SELECT COUNT(account.id) FROM account WHERE synchronize AND state = 'connected') AS accounts" +
" (SELECT COUNT(account.id) FROM account" +
" WHERE synchronize" +
" AND state = 'connected') AS accounts" +
", (SELECT COUNT(operation.id) FROM operation" +
" JOIN folder ON folder.id = operation.folder" +
" JOIN account ON account.id = folder.account" +
" WHERE account.synchronize) AS operations" +
", (SELECT COUNT(message.id) FROM message" +
" JOIN folder ON folder.id = message.folder" +
" JOIN operation ON operation.message = message.id AND operation.name = '" + EntityOperation.SEND + "'" +
" WHERE NOT message.ui_seen" +
" AND folder.type = '" + EntityFolder.OUTBOX + "') AS unsent")
" JOIN folder ON folder.id = operation.folder" +
" JOIN account ON account.id = folder.account" + // not outbox
" WHERE account.synchronize) AS operations" +
", (SELECT COUNT(operation.id) FROM operation" +
" WHERE operation.name = '" + EntityOperation.SEND + "') AS unsent")
LiveData<TupleAccountStats> liveStats();
@Insert