diff --git a/src/Context.cpp b/src/Context.cpp index 0f18d49f0..55d0f3d3f 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -158,16 +158,16 @@ void Context::dispatch () std::string out; /* // Read-only commands with no side effects. - if (command == "export") { out = handleExport (); } + if (command == "export") { out = handleExport (); } */ - if (cmd.command == "projects") { out = handleProjects (); } - else if (cmd.command == "tags") { out = handleTags (); } - else if (cmd.command == "colors") { out = handleColor (); } - else if (cmd.command == "version") { out = handleVersion (); } - else if (cmd.command == "help") { out = longUsage (); } + if (cmd.command == "projects") { out = handleProjects (); } + else if (cmd.command == "tags") { out = handleTags (); } + else if (cmd.command == "colors") { out = handleColor (); } + else if (cmd.command == "version") { out = handleVersion (); } + else if (cmd.command == "help") { out = longUsage (); } + else if (cmd.command == "stats") { out = handleReportStats (); } /* else if (command == "info") { out = handleInfo (); } - else if (command == "stats") { out = handleReportStats (); } else if (command == "history") { out = handleReportHistory (); } else if (command == "ghistory") { out = handleReportGHistory (); } else if (command == "calendar") { out = handleReportCalendar (); } diff --git a/src/main.cpp b/src/main.cpp index 32e4e2111..f7345f5ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -153,67 +153,7 @@ std::string runTaskCommand ( bool gc /* = false */, bool shadow /* = false */) { -/* - // If argc == 1 and there is a default.command, use it. Otherwise use - // argc/argv. - std::string defaultCommand = context.config.get ("default.command"); - if (args.size () == 0 || defaultCommand != "") - { - // Stuff the command line. - args.clear (); - split (args, defaultCommand, ' '); - std::cout << "[task " << defaultCommand << "]" << std::endl; - } - - loadCustomReports (); - - std::string command; - T task; - parse (args, command, task); - - bool gcMod = false; // Change occurred by way of gc. - bool cmdMod = false; // Change occurred by way of command type. -*/ std::string out; -/* - // Read-only commands with no side effects. - if (command == "export") { out = handleExport (tdb, task); } - else if (command == "info") { out = handleInfo (tdb, task); } - else if (command == "stats") { out = handleReportStats (tdb, task); } - else if (command == "history") { out = handleReportHistory (tdb, task); } - else if (command == "ghistory") { out = handleReportGHistory (tdb, task); } - else if (command == "calendar") { out = handleReportCalendar (tdb, task); } - else if (command == "summary") { out = handleReportSummary (tdb, task); } - else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); } - - // Commands that cause updates. - else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (tdb, task); } - else if (command == "add") { cmdMod = true; out = handleAdd (tdb, task); } - else if (command == "append") { cmdMod = true; out = handleAppend (tdb, task); } - else if (command == "annotate") { cmdMod = true; out = handleAnnotate (tdb, task); } - else if (command == "done") { cmdMod = true; out = handleDone (tdb, task); } - else if (command == "undelete") { cmdMod = true; out = handleUndelete (tdb, task); } - else if (command == "delete") { cmdMod = true; out = handleDelete (tdb, task); } - else if (command == "start") { cmdMod = true; out = handleStart (tdb, task); } - else if (command == "stop") { cmdMod = true; out = handleStop (tdb, task); } - else if (command == "undo") { cmdMod = true; out = handleUndo (tdb, task); } - else if (command == "import") { cmdMod = true; out = handleImport (tdb, task); } - else if (command == "duplicate") { cmdMod = true; out = handleDuplicate (tdb, task); } - else if (command == "edit") { cmdMod = true; out = handleEdit (tdb, task); } - - // Command that display IDs and therefore need TDB::gc first. - else if (command == "completed") { if (gc) gcMod = tdb.gc (); out = handleCompleted (tdb, task); } - else if (command == "next") { if (gc) gcMod = tdb.gc (); out = handleReportNext (tdb, task); } - else if (command == "active") { if (gc) gcMod = tdb.gc (); out = handleReportActive (tdb, task); } - else if (command == "overdue") { if (gc) gcMod = tdb.gc (); out = handleReportOverdue (tdb, task); } - else if (isCustomReport (command)) { if (gc) gcMod = tdb.gc (); out = handleCustomReport (tdb, task, command); } - - // Only update the shadow file if such an update was not suppressed (shadow), - // and if an actual change occurred (gcMod || cmdMod). - if (shadow && (gcMod || cmdMod)) - updateShadowFile (tdb); -*/ - return out; } diff --git a/src/report.cpp b/src/report.cpp index be048a1ee..8f366cc2a 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -2241,11 +2241,11 @@ std::string handleReportStats () { std::stringstream out; -/* // Get all the tasks. - std::vector tasks; - tdb.allT (tasks); - filter (tasks, task); + std::vector tasks; + context.tdb.lock (context.config.get ("locking", true)); + context.tdb.load (tasks, context.filter); + context.tdb.unlock (); Date now; time_t earliest = time (NULL); @@ -2262,31 +2262,31 @@ std::string handleReportStats () std::map allTags; std::map allProjects; - std::vector ::iterator it; + std::vector ::iterator it; for (it = tasks.begin (); it != tasks.end (); ++it) { ++totalT; - if (it->getStatus () == T::deleted) ++deletedT; - if (it->getStatus () == T::pending) ++pendingT; - if (it->getStatus () == T::completed) ++completedT; - if (it->getStatus () == T::recurring) ++recurringT; + if (it->getStatus () == Task::deleted) ++deletedT; + if (it->getStatus () == Task::pending) ++pendingT; + if (it->getStatus () == Task::completed) ++completedT; + if (it->getStatus () == Task::recurring) ++recurringT; - time_t entry = ::atoi (it->getAttribute ("entry").c_str ()); + time_t entry = ::atoi (it->get ("entry").c_str ()); if (entry < earliest) earliest = entry; if (entry > latest) latest = entry; - if (it->getStatus () == T::completed) + if (it->getStatus () == Task::completed) { - time_t end = ::atoi (it->getAttribute ("end").c_str ()); + time_t end = ::atoi (it->get ("end").c_str ()); daysPending += (end - entry) / 86400.0; } - if (it->getStatus () == T::pending) + if (it->getStatus () == Task::pending) daysPending += (now - entry) / 86400.0; - descLength += it->getDescription ().length (); + descLength += it->get ("description").length (); - std::map annotations; + std::vector annotations; it->getAnnotations (annotations); annotationsT += annotations.size (); @@ -2297,7 +2297,7 @@ std::string handleReportStats () foreach (t, tags) allTags[*t] = 0; - std::string project = it->getAttribute ("project"); + std::string project = it->get ("project"); if (project != "") allProjects[project] = 0; } @@ -2424,7 +2424,7 @@ std::string handleReportStats () out << optionalBlankLine () << table.render () << optionalBlankLine (); -*/ + return out.str (); }