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/account.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/account.cc')
-rw-r--r-- | src/account.cc | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/account.cc b/src/account.cc index b9955120..0db42cdb 100644 --- a/src/account.cc +++ b/src/account.cc @@ -309,7 +309,36 @@ std::size_t account_t::children_with_flags(xdata_t::flags_t flags) const account_t::xdata_t::details_t& account_t::xdata_t::details_t::operator+=(const details_t& other) { - // jww (2009-03-05): NYI + posts_count += other.posts_count; + posts_virtuals_count += other.posts_virtuals_count; + posts_cleared_count += other.posts_cleared_count; + posts_last_7_count += other.posts_last_7_count; + posts_last_30_count += other.posts_last_30_count; + posts_this_month_count += other.posts_this_month_count; + + if (! is_valid(earliest_post) || + (is_valid(other.earliest_post) && + other.earliest_post < earliest_post)) + earliest_post = other.earliest_post; + if (! is_valid(earliest_cleared_post) || + (is_valid(other.earliest_cleared_post) && + other.earliest_cleared_post < earliest_cleared_post)) + earliest_cleared_post = other.earliest_cleared_post; + + if (! is_valid(latest_post) || + (is_valid(other.latest_post) && + other.latest_post > latest_post)) + latest_post = other.latest_post; + if (! is_valid(latest_cleared_post) || + (is_valid(other.latest_cleared_post) && + other.latest_cleared_post > latest_cleared_post)) + latest_cleared_post = other.latest_cleared_post; + + filenames.insert(other.filenames.begin(), other.filenames.end()); + accounts_referenced.insert(other.accounts_referenced.begin(), + other.accounts_referenced.end()); + payees_referenced.insert(other.payees_referenced.begin(), + other.payees_referenced.end()); return *this; } @@ -377,7 +406,7 @@ account_t::family_details(bool gather_all) const foreach (const accounts_map::value_type& pair, accounts) xdata_->family_details += pair.second->family_details(gather_all); - xdata_->self_details += self_details(gather_all); + xdata_->family_details += self_details(gather_all); } return xdata_->family_details; } @@ -385,16 +414,8 @@ account_t::family_details(bool gather_all) const void account_t::xdata_t::details_t::update(post_t& post, bool gather_all) { - if (last_xact != post.xact) { - xacts_count++; - last_xact = post.xact; - } - if (last_post == &post) - return; - - last_post = &post; - posts_count++; + if (post.has_flags(POST_VIRTUAL)) posts_virtuals_count++; |