From 541086d3463c1c77105f3da3633640a2cbb970b5 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Mon, 11 Nov 2024 15:26:17 +1100 Subject: [PATCH] More efficient implementation for all_accounts --- drcr/webapp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drcr/webapp.py b/drcr/webapp.py index 312ca9c..dae6e90 100644 --- a/drcr/webapp.py +++ b/drcr/webapp.py @@ -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"""