public function run($arguments, CLImaxController $cliController) { // Set up options for search $config = GitPlanbox_Config::get(); $statuses = array('completed', 'delivered', 'accepted'); $opts = array('productid' => $config->productid(), 'timeframe' => $timeframe, 'status' => $statuses); // Pull in timeframe(s) if they've been specified if (isset($arguments[0])) { $opts['timeframe'] = explode(',', $arguments[0]); } else { $opts['timeframe'] = array('last', 'current', 'next'); } // Create a session so we can run commands $session = GitPlanbox_Session::create(); // Get a list of stories $stories = GitPlanbox_Search::search($session, $opts); if (count($stories) == 0) { print "There are no stories in status: " . implode(', ', $statuses) . ".\n"; return 0; } // Format stories nicely print "Stories that are ready for release:\n"; foreach ($stories as $story) { printf("%8s %10s - %-50s\n", "#{$story->id}", $story->status, $story->name); } print "\nHint: use `git-planbox status <storyId>` to find out what branch the story is on.\n\n"; return 0; }
public static function create() { // Pull out config vars $config = GitPlanbox_Config::get(); // Call out to planbox to start a session return new self($config); }
private function _stopRunningTimers($session) { $config = GitPlanbox_Config::get(); // Don't change any timers unless they're managed by this user if (!$config->resourceid()) { return; } // Fetch stories $postData = array('product_id' => $config->productid(), 'resource_id' => $config->resourceid()); $stories = $session->post('get_stories', $postData); // Find tasks that are in progress $inProgress = array(); foreach ($stories as $story) { $storyHasTasksInProgress = false; foreach ($story->tasks as $task) { if ($task->status == 'inprogress') { $storyHasTasksInProgress = true; } } if ($storyHasTasksInProgress) { array_push($inProgress, $story); } } // Ask the user if they'd like to pause the running timers if (count($inProgress) > 0) { print "The following stories have one or more tasks in progress:\n"; foreach ($inProgress as $story) { printf("%8s %10s - %-50s\n", "#{$story->id}", $story->status, $story->name); } $response = GitPlanbox_Util::readline("Pause (p), finish (f), or ignore (i) these tasks? [P/f/i] "); if ($response == '' || strtolower($response) == 'p' || strtolower($response) == 'pause') { foreach ($inProgress as $story) { foreach ($story->tasks as $task) { if ($task->status != 'inprogress') { continue; } // Stop the timer $postData = array('story_id' => $story->id, 'task_id' => $task->id, 'status' => 'pending'); $session->post('update_task', $postData); } } print "Paused timers for " . count($inProgress) . " stories.\n"; } else { if (strtolower($response) == 'f' || strtolower($response) == 'finish') { foreach ($inProgress as $story) { foreach ($story->tasks as $task) { if ($task->status != 'inprogress') { continue; } // Stop the timer $postData = array('story_id' => $story->id, 'task_id' => $task->id, 'status' => 'completed'); $session->post('update_task', $postData); } } print "Finished " . count($inProgress) . " stories.\n"; } } } }
public function run($arguments, CLImaxController $cliController) { // Pull in iterations if they've been specified, otherwise // use current as default $timeframe = 'current'; if (isset($arguments[0])) { $timeframe = explode(',', $arguments[0]); } // Create a session so we can run commands $session = GitPlanbox_Session::create(); // Get a list of stories $config = GitPlanbox_Config::get(); $postData = array('product_id' => $config->productid(), 'timeframe' => $timeframe); if ($config->resourceid()) { $postData['resource_id'] = array($config->resourceid()); } // Restrict list to the current user if they have specified a planbox.resourceid in gitconfig $stories = $session->post('get_stories', $postData); // Format stories nicely $skippedStoriesByStatus = array(); foreach ($stories as $story) { // Skip stories that are done $statusesToSkip = array('completed', 'delivered', 'accepted', 'rejected', 'released', 'blocked'); if (in_array($story->status, $statusesToSkip)) { if (!isset($skippedStoriesByStatus[$story->status])) { $skippedStoriesByStatus[$story->status] = 0; } $skippedStoriesByStatus[$story->status]++; continue; } printf("%8s %9s %10s - %-50s\n", "#{$story->id}", $story->type, $story->status, $story->name); } if (!empty($skippedStoriesByStatus)) { $skippedStoryStatuses = array(); foreach ($skippedStoriesByStatus as $status => $numSkipped) { array_push($skippedStoryStatuses, "{$numSkipped} {$status}"); } print "...plus " . implode(', ', $skippedStoryStatuses) . " tasks that are not displayed.\n"; } return 0; }