| 284 | //////////////////////////////////////////////////////////////////////////////// |
| 285 | template <class HistoryStrategy> |
| 286 | int CmdHistoryBase<HistoryStrategy>::execute(std::string& output) { |
| 287 | rc = 0; |
| 288 | |
| 289 | // TODO is this necessary? |
| 290 | groups.clear(); |
| 291 | addedGroup.clear(); |
| 292 | deletedGroup.clear(); |
| 293 | completedGroup.clear(); |
| 294 | |
| 295 | // Apply filter. |
| 296 | Filter filter; |
| 297 | std::vector<Task> filtered; |
| 298 | filter.subset(filtered); |
| 299 | |
| 300 | for (auto& task : filtered) { |
| 301 | Datetime entry(task.get_date("entry")); |
| 302 | |
| 303 | Datetime end; |
| 304 | if (task.has("end")) end = Datetime(task.get_date("end")); |
| 305 | |
| 306 | auto epoch = HistoryStrategy::getRelevantDate(entry).toEpoch(); |
| 307 | groups[epoch] = 0; |
| 308 | |
| 309 | // Every task has an entry date, but exclude templates. |
| 310 | if (task.getStatus() != Task::recurring) ++addedGroup[epoch]; |
| 311 | |
| 312 | // All deleted tasks have an end date. |
| 313 | if (task.getStatus() == Task::deleted) { |
| 314 | epoch = HistoryStrategy::getRelevantDate(end).toEpoch(); |
| 315 | groups[epoch] = 0; |
| 316 | ++deletedGroup[epoch]; |
| 317 | } |
| 318 | |
| 319 | // All completed tasks have an end date. |
| 320 | else if (task.getStatus() == Task::completed) { |
| 321 | epoch = HistoryStrategy::getRelevantDate(end).toEpoch(); |
| 322 | groups[epoch] = 0; |
| 323 | ++completedGroup[epoch]; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | // Now build the view. |
| 328 | if (HistoryStrategy::graphical) |
| 329 | this->outputGraphical(output); |
| 330 | else |
| 331 | this->outputTabular(output); |
| 332 | |
| 333 | return rc; |
| 334 | } |
| 335 | |
| 336 | ////////////////////////////////////////////////////////////////////////////i |
| 337 | class MonthlyGHistoryStrategy { |
nothing calls this directly
no test coverage detected