From 39e1e3cb7fea21d541869f787b9c1379e976df2d Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 23 Apr 2021 22:29:02 +0300 Subject: [PATCH] async variant for loading all transactions --- .../java/net/ktnx/mobileledger/dao/TransactionDAO.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java index 8f238183..5af78ea9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java +++ b/app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java @@ -115,6 +115,15 @@ public abstract class TransactionDAO extends BaseDAO { public abstract List getAllWithAccountsFilteredSync(long profileId, String accountName); + @androidx.room.Transaction + @Query("SELECT distinct(tr.id), tr.ledger_id, tr.profile_id, tr.data_hash, tr.year, tr.month," + + " tr.day, tr.description, tr.comment, tr.generation FROM transactions tr JOIN " + + "transaction_accounts ta ON ta.transaction_id=tr.id WHERE ta.account_name LIKE " + + ":accountName||'%' AND ta.amount <> 0 AND tr.profile_id = :profileId ORDER BY tr.year " + + "desc, tr.month desc, tr.day desc, tr.ledger_id desc") + public abstract LiveData> getAllWithAccountsFiltered( + long profileId, String accountName); + @Query("DELETE FROM transactions WHERE profile_id = :profileId AND generation <> " + ":currentGeneration") public abstract int purgeOldTransactionsSync(long profileId, long currentGeneration); -- 2.39.5