make TDB2.undo non-public
The stats command calls an API to provide this information in a way that will still be relevant for TaskChampion, while CmdInfo's access to the data remains. The TaskChampion interface for per-task hitsory is still not ready.
This commit is contained in:
committed by
Tomas Babej
parent
2f30bc8cbf
commit
4ebd0ffb39
@@ -1266,6 +1266,13 @@ int TDB2::num_local_changes ()
|
||||
return std::count_if(lines.begin(), lines.end(), [](const auto& line){ return line.front() == '{'; });
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int TDB2::num_reverts_possible ()
|
||||
{
|
||||
std::vector <std::string> lines = undo.get_lines ();
|
||||
return std::count(lines.begin(), lines.end(), "---");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t TDB2::data_size ()
|
||||
{
|
||||
|
||||
@@ -136,6 +136,7 @@ public:
|
||||
bool read_only ();
|
||||
|
||||
int num_local_changes ();
|
||||
int num_reverts_possible ();
|
||||
size_t data_size ();
|
||||
|
||||
void clear ();
|
||||
@@ -154,11 +155,12 @@ private:
|
||||
public:
|
||||
TF2 pending;
|
||||
TF2 completed;
|
||||
TF2 undo;
|
||||
|
||||
protected:
|
||||
friend class CmdSync; // CmdSync accesses the backlog directly
|
||||
TF2 backlog;
|
||||
friend class CmdInfo; // CmdInfo uses undo data to give history
|
||||
TF2 undo;
|
||||
|
||||
private:
|
||||
std::string _location;
|
||||
|
||||
@@ -65,9 +65,8 @@ int CmdStats::execute (std::string& output)
|
||||
// Go get the file sizes.
|
||||
size_t dataSize = Context::getContext ().tdb2.data_size ();
|
||||
|
||||
// Count the undo transactions.
|
||||
std::vector <std::string> undoTxns = Context::getContext ().tdb2.undo.get_lines ();
|
||||
int undoCount = std::count(undoTxns.begin(), undoTxns.end(), "---");
|
||||
// Count the possible reverts.
|
||||
int undoCount = Context::getContext ().tdb2.num_reverts_possible ();
|
||||
|
||||
// Count the backlog transactions.
|
||||
int numLocalChanges = Context::getContext ().tdb2.num_local_changes ();
|
||||
|
||||
Reference in New Issue
Block a user