diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-06 04:05:00 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-06 04:07:25 -0400 |
commit | f340d50362340c330de83d419eb41c0ede162c49 (patch) | |
tree | 9a30d7bd034c3fa37092725d419f896108536633 /src/output.cc | |
parent | 4a0f5f9034dc24c7ae5f0464d407f4cf2279558b (diff) | |
download | fork-ledger-f340d50362340c330de83d419eb41c0ede162c49.tar.gz fork-ledger-f340d50362340c330de83d419eb41c0ede162c49.tar.bz2 fork-ledger-f340d50362340c330de83d419eb41c0ede162c49.zip |
Revised the ways statistics are computed
It is no longer done in calc_posts, but recursively on each account.
This allows value expressions to ask statistical questions, like
"earliest cleared posting?" (TBD) from any specific account, computed
lazily.
Diffstat (limited to 'src/output.cc')
-rw-r--r-- | src/output.cc | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/src/output.cc b/src/output.cc index 975d8077..02bd7120 100644 --- a/src/output.cc +++ b/src/output.cc @@ -111,104 +111,6 @@ void format_posts::operator()(post_t& post) } } -void gather_statistics::flush() -{ - std::ostream& out(report.output_stream); - - { - straccstream accum; - out << ACCUM(accum << "Time period: %1 to %2" << statistics.earliest_post - << statistics.latest_post) << std::endl << std::endl; - } - - out << _(" Files these postings came from:") << std::endl; - - foreach (const path& pathname, statistics.filenames) - if (! pathname.empty()) - out << " " << pathname.string() << std::endl; - out << std::endl; - - out << _(" Unique payees: "); - out.width(8); - out << std::right << statistics.payees_referenced.size() << std::endl; - - out << _(" Unique accounts: "); - out.width(8); - out << std::right << statistics.accounts_referenced.size() << std::endl; - - out << _(" Number of transactions: ") ; - out.width(8); - out << std::right << statistics.total_xacts << std::endl; - - out << _(" Number of postings: "); - out.width(8); - out << std::right << statistics.total_posts; - - out << " ("; - out.precision(2); - out << (double((statistics.latest_post - statistics.earliest_post).days()) / - double(statistics.total_posts)) << _(" per day)") << std::endl; - - out << _(" Days since last post: "); - out.width(8); - out << std::right << (CURRENT_DATE() - statistics.latest_post).days() - << std::endl; - - out << _(" Posts in last 7 days: "); - out.width(8); - out << std::right << statistics.total_last_7_days << std::endl; - out << _(" Posts in last 30 days: "); - out.width(8); - out << std::right << statistics.total_last_30_days << std::endl; - out << _(" Posts seen this month: "); - out.width(8); - out << std::right << statistics.total_this_month << std::endl; - - out << _(" Uncleared postings: "); - out.width(8); - out << std::right << statistics.total_uncleared_posts << std::endl; - - out.flush(); -} - -void gather_statistics::operator()(post_t& post) -{ - if (last_xact != post.xact) { - statistics.total_xacts++; - last_xact = post.xact; - } - if (last_post != &post) { - statistics.total_posts++; - last_post = &post; - - statistics.filenames.insert(post.pathname); - - date_t date = post.date(); - - if (date.year() == CURRENT_DATE().year() && - date.month() == CURRENT_DATE().month()) - statistics.total_this_month++; - - if ((CURRENT_DATE() - date).days() <= 30) - statistics.total_last_30_days++; - if ((CURRENT_DATE() - date).days() <= 7) - statistics.total_last_7_days++; - - if (post.state() != item_t::CLEARED) - statistics.total_uncleared_posts++; - - if (! is_valid(statistics.earliest_post) || - post.date() < statistics.earliest_post) - statistics.earliest_post = post.date(); - if (! is_valid(statistics.latest_post) || - post.date() > statistics.latest_post) - statistics.latest_post = post.date(); - - statistics.accounts_referenced.insert(post.account->fullname()); - statistics.payees_referenced.insert(post.xact->payee); - } -} - format_accounts::format_accounts(report_t& _report, const string& format) : report(_report), disp_pred() |