More efficient implementation for all_accounts

This commit is contained in:
RunasSudo 2024-11-11 15:26:17 +11:00
parent e25855450c
commit 541086d346
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -75,8 +75,9 @@ def api_transactions(start_date=None, end_date=None):
return transactions
def all_accounts():
# TODO: Can this be cached?
return sorted(list(set(p.account for t in all_transactions() for p in t.postings)))
"""Return all accounts in alphabetical order"""
return db.session.scalars('SELECT DISTINCT account FROM postings ORDER BY account').all()
def eofy_date():
"""Get the datetime for the end of the financial year"""