dev: reg: areg: Strip prices early on in PostingsReport and AccountTransactionsReport, when possible.

This results in big speedups in cases when we have many transaction prices, like in examples/10000x1000x10.journal. This can be disabled with the show_costs_ option in ReportOpts.
This commit is contained in:
Stephen Morgan 2022-02-07 16:23:10 +11:00 committed by Simon Michael
parent 25e3cca2e1
commit 45408183fe
3 changed files with 13 additions and 1 deletions

View File

@ -116,7 +116,12 @@ accountTransactionsReport rspec@ReportSpec{_rsReportOpts=ropts} j thisacctq = it
-- Additional reportq filtering, such as date filtering, happens down in
-- accountTransactionsReportItem, which discards transactions with no matched postings.
acctJournal =
ptraceAtWith 5 (("ts3:\n"++).pshowTransactions.jtxns)
-- With most calls we will not require transaction prices past this point, and can get a big
-- speed improvement by stripping them early. In some cases, such as in hledger-ui, we still
-- want to keep prices around, so we can toggle between cost and no cost quickly. We can use
-- the show_costs_ flag to be efficient when we can, and detailed when we have to.
(if show_costs_ ropts then id else journalMapPostingAmounts mixedAmountStripPrices)
. ptraceAtWith 5 (("ts3:\n"++).pshowTransactions.jtxns)
-- maybe convert these transactions to cost or value
. journalApplyValuationFromOpts rspec
. ptraceAtWith 5 (("ts2:\n"++).pshowTransactions.jtxns)

View File

@ -120,6 +120,11 @@ matchedPostingsBeforeAndDuring rspec@ReportSpec{_rsReportOpts=ropts,_rsQuery=q}
sortOn (postingDateOrDate2 (whichDate ropts)) -- sort postings by date or date2
. (if invert_ ropts then map negatePostingAmount else id) -- with --invert, invert amounts
. journalPostings
-- With most calls we will not require transaction prices past this point, and can get a big
-- speed improvement by stripping them early. In some cases, such as in hledger-ui, we still
-- want to keep prices around, so we can toggle between cost and no cost quickly. We can use
-- the show_costs_ flag to be efficient when we can, and detailed when we have to.
. (if show_costs_ ropts then id else journalMapPostingAmounts mixedAmountStripPrices)
$ journalValueAndFilterPostings rspec{_rsQuery=beforeandduringq} j
-- filter postings by the query, with no start date or depth limit

View File

@ -69,6 +69,8 @@ rsInit d reset ui@UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec
ropts' = ropts {
-- ignore any depth limit, as in postingsReport; allows register's total to match accounts screen
depth_=Nothing
-- do not strip prices so we can toggle costs within the ui
, show_costs_=True
-- XXX aregister also has this, needed ?
-- always show historical balance
-- , balanceaccum_= Historical