From 2623d101e7027975ccbd424f77391910911e354d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 16 Feb 2018 21:50:14 -0500 Subject: [PATCH] - Thanks to php-coder --- AUTHORS | 1 + ChangeLog | 4 +- src/commands/CmdBurndown.cpp | 85 ++++++++++-------------------------- test/burndown.t | 8 ++-- 4 files changed, 32 insertions(+), 66 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0176697bc..2dde4c6fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -322,3 +322,4 @@ suggestions: Kai HTML Marc Richter rjc + php-coder diff --git a/ChangeLog b/ChangeLog index 78d6b136b..00092677e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,7 +76,9 @@ - TW-1938 Adjust behaviour of new-uuid and new-id verbosity levels (thanks to Paul J. Fenwick) - TW-1947 "urgency.over" filter seems to not work correct - (thanks to Marc Richter). + (thanks to Marc Richter) +- #1964 task burndown shows extra brackets #1964 + (thanks to php-coder) - Added 'juhannus' as a synonym for 'midsommarafton' (thanks to Lynoure Braakman). - Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY' diff --git a/src/commands/CmdBurndown.cpp b/src/commands/CmdBurndown.cpp index 6dfafa1e2..c745bd423 100644 --- a/src/commands/CmdBurndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -144,27 +144,25 @@ private: unsigned burndown_size (unsigned); public: - int _width; // Terminal width - int _height; // Terminal height - int _graph_width; // Width of plot area - int _graph_height; // Height of plot area - int _max_value; // Largest combined bar value - int _max_label; // Longest y-axis label - std::vector _labels; // Y-axis labels - int _estimated_bars; // Estimated bar count - int _actual_bars; // Calculated bar count - std::map _bars; // Epoch-indexed set of bars - Datetime _earliest; // Date of earliest estimated bar - int _carryover_done; // Number of 'done' tasks prior to chart range - char _period; // D, W, M - std::string _title; // Additional description - std::string _grid; // String representing grid of characters - - time_t _peak_epoch; // Quantized (D) date of highest pending peak - int _peak_count; // Corresponding peak pending count - int _current_count; // Current pending count - float _net_fix_rate; // Calculated fix rate - std::string _completion; // Estimated completion date + int _width {}; // Terminal width + int _height {}; // Terminal height + int _graph_width {}; // Width of plot area + int _graph_height {}; // Height of plot area + int _max_value {0}; // Largest combined bar value + int _max_label {1}; // Longest y-axis label + std::vector _labels {}; // Y-axis labels + int _estimated_bars {}; // Estimated bar count + int _actual_bars {0}; // Calculated bar count + std::map _bars {}; // Epoch-indexed set of bars + Datetime _earliest {}; // Date of earliest estimated bar + int _carryover_done {0}; // Number of 'done' tasks prior to chart range + char _period {}; // D, W, M + std::string _grid {}; // String representing grid of characters + time_t _peak_epoch {}; // Quantized (D) date of highest pending peak + int _peak_count {0}; // Corresponding peak pending count + int _current_count {0}; // Current pending count + float _net_fix_rate {0.0}; // Calculated fix rate + std::string _completion {}; // Estimated completion date }; //////////////////////////////////////////////////////////////////////////////// @@ -174,8 +172,6 @@ Chart::Chart (char type) // maximum space, and the width drives various other parameters. _width = Context::getContext ().getWidth (); _height = Context::getContext ().getHeight () - 1; // Allow for new line with prompt. - _max_value = 0; - _max_label = 1; _graph_height = _height - 7; _graph_width = _width - _max_label - 14; @@ -183,17 +179,7 @@ Chart::Chart (char type) // potentially enormous data set. _estimated_bars = (_width - 1 - 14) / 3; - _actual_bars = 0; _period = type; - _carryover_done = 0; - - // Rates are calculated last. - _net_fix_rate = 0.0; - - // Set the title. - std::vector words = Context::getContext ().cli2.getWords (); - auto filter = join (" ", words); - _title = '(' + filter + ')'; } //////////////////////////////////////////////////////////////////////////////// @@ -229,7 +215,6 @@ void Chart::scanForPeak (std::vector & tasks) } // Find the peak, peak date and current. - _peak_count = 0; for (auto& count : pending) { if (count.second > _peak_count) @@ -402,33 +387,11 @@ std::string Chart::render () _grid += std::string (_width, ' ') + '\n'; // Title. - std::string full_title; - switch (_period) - { - case 'D': full_title = "Daily"; break; - case 'W': full_title = "Weekly"; break; - case 'M': full_title = "Monthly"; break; - } - - full_title += std::string (" Burndown"); - - if (_title.length ()) - { - if (full_title.length () + 1 + _title.length () < (unsigned) _width) - { - full_title += ' ' + _title; - _grid.replace (LOC (0, (_width - full_title.length ()) / 2), full_title.length (), full_title); - } - else - { - _grid.replace (LOC (0, (_width - full_title.length ()) / 2), full_title.length (), full_title); - _grid.replace (LOC (1, (_width - _title.length ()) / 2), _title.length (), _title); - } - } - else - { - _grid.replace (LOC (0, (_width - full_title.length ()) / 2), full_title.length (), full_title); - } + std::string title = _period == 'D' ? "Daily" + : _period == 'W' ? "Weekly" + : "Monthly"; + title += std::string (" Burndown"); + _grid.replace (LOC (0, (_width - title.length ()) / 2), title.length (), title); // Legend. _grid.replace (LOC (_graph_height / 2 - 1, _width - 10), 10, "DD " + leftJustify ("Done", 7)); diff --git a/test/burndown.t b/test/burndown.t index c976719a1..ddee43831 100755 --- a/test/burndown.t +++ b/test/burndown.t @@ -59,7 +59,7 @@ class TestBurndownCommand(TestCase): def test_burndown_daily(self): """Ensure burndown.daily generates a chart""" code, out, err = self.t("burndown.daily") - self.assertIn("Daily Burndown ()", out) + self.assertIn("Daily Burndown", out) self.assertIn(".", out) self.assertIn("+", out) self.assertIn("X", out) @@ -67,13 +67,13 @@ class TestBurndownCommand(TestCase): def test_burndown_daily_color(self): """Ensure burndown.daily with color, generates a chart""" code, out, err = self.t("burndown.daily rc._forcecolor:on") - self.assertIn("Daily Burndown ()", out) + self.assertIn("Daily Burndown", out) self.assertNotIn("X", out) def test_burndown_weekly(self): """Ensure burndown.weekly generates a chart""" code, out, err = self.t("burndown.weekly") - self.assertIn("Weekly Burndown ()", out) + self.assertIn("Weekly Burndown", out) self.assertIn(".", out) self.assertIn("+", out) self.assertIn("X", out) @@ -81,7 +81,7 @@ class TestBurndownCommand(TestCase): def test_burndown_monthly(self): """Ensure burndown.monthly generates a chart""" code, out, err = self.t("burndown.monthly") - self.assertIn("Monthly Burndown ()", out) + self.assertIn("Monthly Burndown", out) self.assertIn(".", out) self.assertIn("+", out) self.assertIn("X", out)