From eeb647944022b30cf4c6e929794f33a7af60adeb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 28 Aug 2011 00:16:24 -0400 Subject: [PATCH] Command: Statistics - Modified implementation to make better use of TDB2 features, and remove a set of static strings. --- src/commands/CmdStatistics.cpp | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/commands/CmdStatistics.cpp b/src/commands/CmdStatistics.cpp index c4fc06dd5..43e521ad8 100644 --- a/src/commands/CmdStatistics.cpp +++ b/src/commands/CmdStatistics.cpp @@ -60,30 +60,18 @@ int CmdStatistics::execute (std::string& output) std::string dateformat = context.config.get ("dateformat"); // Go get the file sizes. - size_t dataSize = 0; + size_t dataSize = context.tdb2.pending._file.size () + + context.tdb2.completed._file.size () + + context.tdb2.undo._file.size () + + context.tdb2.backlog._file.size () + + context.tdb2.synch_key._file.size (); - Directory location (context.config.get ("data.location")); - File pending (location._data + "/pending.data"); - dataSize += pending.size (); - - File completed (location._data + "/completed.data"); - dataSize += completed.size (); - - File undo (location._data + "/undo.data"); - dataSize += undo.size (); - - File backlog (location._data + "/backlog.data"); - dataSize += backlog.size (); - - File synch_key (location._data + "/synch_key.data"); - dataSize += synch_key.size (); - - std::vector undoTxns; - File::read (undo, undoTxns); + // Count the undo transactions. + std::vector undoTxns = context.tdb2.undo.get_lines (); int undoCount = 0; std::vector ::iterator tx; for (tx = undoTxns.begin (); tx != undoTxns.end (); ++tx) - if (tx->substr (0, 3) == "---") + if (*tx == "---") ++undoCount; // Get all the tasks.