mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
Extend bug fix of #1917 to summary command
This commit is contained in:
parent
54a57e9954
commit
28974cd794
1 changed files with 29 additions and 10 deletions
|
@ -150,9 +150,28 @@ int CmdSummary::execute (std::string& output)
|
||||||
std::vector <std::string> processed;
|
std::vector <std::string> processed;
|
||||||
for (auto& i : allProjects)
|
for (auto& i : allProjects)
|
||||||
{
|
{
|
||||||
if (showAllProjects || countPending[i.first] > 0)
|
// store project name
|
||||||
|
std::string project_name = i.first;
|
||||||
|
// catch project names including '-'
|
||||||
|
if (project_name.find ('-') != std::string::npos)
|
||||||
{
|
{
|
||||||
const std::vector <std::string> parents = extractParents (i.first);
|
// replace '-' with '=' which has a higher ASCII code
|
||||||
|
// and will therefore be processed later
|
||||||
|
std::string new_project = project_name;
|
||||||
|
std::replace(new_project.begin (), new_project.end (), '-', '=');
|
||||||
|
allProjects[new_project] = i.second;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// catch project names including '='
|
||||||
|
// (assuming the user did not create any such projects himself)
|
||||||
|
if (project_name.find ('=') != std::string::npos)
|
||||||
|
{
|
||||||
|
// revert '=' into '-' for correct displaying
|
||||||
|
std::replace(project_name.begin (), project_name.end (), '=', '-');
|
||||||
|
}
|
||||||
|
if (showAllProjects || countPending[project_name] > 0)
|
||||||
|
{
|
||||||
|
const std::vector <std::string> parents = extractParents (project_name);
|
||||||
for (auto& parent : parents)
|
for (auto& parent : parents)
|
||||||
{
|
{
|
||||||
if (std::find (processed.begin (), processed.end (), parent)
|
if (std::find (processed.begin (), processed.end (), parent)
|
||||||
|
@ -165,16 +184,16 @@ int CmdSummary::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = view.addRow ();
|
int row = view.addRow ();
|
||||||
view.set (row, 0, (i.first == ""
|
view.set (row, 0, (project_name == ""
|
||||||
? "(none)"
|
? "(none)"
|
||||||
: indentProject (i.first, " ", '.')));
|
: indentProject (project_name, " ", '.')));
|
||||||
|
|
||||||
view.set (row, 1, countPending[i.first]);
|
view.set (row, 1, countPending[project_name]);
|
||||||
if (counter[i.first])
|
if (counter[project_name])
|
||||||
view.set (row, 2, Duration ((int) (sumEntry[i.first] / (double)counter[i.first])).formatVague ());
|
view.set (row, 2, Duration ((int) (sumEntry[project_name] / (double)counter[project_name])).formatVague ());
|
||||||
|
|
||||||
int c = countCompleted[i.first];
|
int c = countCompleted[project_name];
|
||||||
int p = countPending[i.first];
|
int p = countPending[project_name];
|
||||||
int completedBar = 0;
|
int completedBar = 0;
|
||||||
if (c + p)
|
if (c + p)
|
||||||
completedBar = (c * barWidth) / (c + p);
|
completedBar = (c * barWidth) / (c + p);
|
||||||
|
@ -197,7 +216,7 @@ int CmdSummary::execute (std::string& output)
|
||||||
if (c + p)
|
if (c + p)
|
||||||
snprintf (percent, 12, "%d%%", 100 * c / (c + p));
|
snprintf (percent, 12, "%d%%", 100 * c / (c + p));
|
||||||
view.set (row, 3, percent);
|
view.set (row, 3, percent);
|
||||||
processed.push_back (i.first);
|
processed.push_back (project_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue