/** * Returns if a sprint in a project is complete * @return boolean */ public function isComplete() { $issuesCount = $this->issues()->select('status_id')->where('sprint_id', '=', $this->id)->where('project_id', '=', $this->project_id)->count(); $issuesCompletedCount = $this->issues()->select('status_id')->where('sprint_id', '=', $this->id)->where('project_id', '=', $this->project_id)->whereIn('status_id', array(IssueStatus::getIdByMachineName('complete'), IssueStatus::getIdByMachineName('archive')))->count(); if ($issuesCompletedCount == $issuesCount) { return true; } return false; }
/** * Get the list of issues in a sprint by issue status * @param string $issueStatusMachineName * @param int $sprintId */ public static function getIssuesInSprintByIssueStatus($issueStatusMachineName, $sprintId) { $statusId = IssueStatus::getIdByMachineName($issueStatusMachineName); if ($statusId) { return Issue::where('sprint_id', '=', $sprintId)->where('status_id', '=', $statusId)->get(); } else { return false; } }
/** * Execute the console command. * * @return mixed */ public function handle() { $currentTimestamp = Carbon::now()->toDateTimeString(); $tomorrowTimestamp = Carbon::now()->addDay()->toDateTimeString(); $issuesWithDeadlineWithinADay = DB::table('issues')->select('id', 'deadline', 'title')->where('deadline', '>=', $currentTimestamp)->where('deadline', '<', $tomorrowTimestamp)->where('status_id', '!=', IssueStatus::getIdByMachineName('complete'))->where('status_id', '!=', IssueStatus::getIdByMachineName('archive'))->get(); Mail::send('emails.issuesDeadlineReminder', ['issuesWithDeadlineWithinADay' => $issuesWithDeadlineWithinADay], function ($message) { $message->from(env('MAIL_FROM_ADDRESS'), env('APP_NAME')); $message->to('*****@*****.**', 'Srikanth AD')->subject('Daily report: issues with deadlines within a day'); }); }
/** * Update the status of an issue * @return string */ public function statuschange() { $result = 'There was an error updating the issue status'; $issueStatusMachineNames = IssueStatus::lists('machine_name', 'id')->all(); $newIssueStatusMachineName = trim(strip_tags(Request::get('machineNameOfNewIssueStatus'))); $prevIssueId = trim(strip_tags(Request::get('prevIssueId'))); $nextIssueId = trim(strip_tags(Request::get('nextIssueId'))); if (in_array($newIssueStatusMachineName, $issueStatusMachineNames)) { $issueId = (int) trim(Request::get('issueId')); $statusId = array_search($newIssueStatusMachineName, $issueStatusMachineNames); $issue = Issue::findOrFail($issueId); if ($issue) { DB::update('update issues set status_id = ? where id = ?', [$statusId, $issueId]); $result = 'Issue status has been changed successfully.'; // If an issue is archived set sort order (previous and next) to NULL if ($newIssueStatusMachineName == 'archive') { // Check if previous and next issue ids provided in the Request exist in the sprint if ($prevIssueId && Sprint::find($issue->sprint_id)->issues()->where('id', '=', $issue->id)->first()->id) { // do nothing } else { $prevIssueId = NULL; } if ($nextIssueId && Sprint::find($issue->sprint_id)->issues()->where('id', '=', $issue->id)->first()->id) { // do nothing } else { $nextIssueId = NULL; } // set sort order for previous and next issues in the same sprint if ($prevIssueId) { $prevIssue = Issue::findOrFail($prevIssueId); $prevIssue->sort_next = $issue->sort_next ? $issue->sort_next : NULL; $prevIssue->save(); } if ($nextIssueId) { $nextIssue = Issue::findOrFail($nextIssueId); $nextIssue->sort_prev = $issue->sort_prev ? $issue->sort_prev : NULL; $nextIssue->save(); } // set sort_prev and sort_next for archived issue to NULL $archivedIssue = Issue::findOrFail($issueId); $archivedIssue->sort_prev = NULL; $archivedIssue->sort_next = NULL; $archivedIssue->save(); } } } return $result; }
/** * Update the status of an issue * @return string */ public function statuschange() { $result = 'There was an error updating the issue status'; $issueStatusMachineNames = IssueStatus::lists('machine_name', 'id')->all(); $newIssueStatusMachineName = trim(Request::get('machineNameOfNewIssueStatus')); if (in_array($newIssueStatusMachineName, $issueStatusMachineNames)) { $issueId = (int) trim(Request::get('issueId')); $statusId = array_search($newIssueStatusMachineName, $issueStatusMachineNames); if (Issue::find($issueId) != NULL) { DB::update('update issues set status_id = ? where id = ?', [$statusId, $issueId]); $result = 'Issue status has been changed successfully.'; } } return $result; }
/** * Return the collection of issue statuses * @return Response */ public function index() { $issuestatuses = IssueStatus::all(); return $issuestatuses; }
/** * getLatestIssueInSprint Get the latest issue from a sprint - by created at date * @return latest issue in sprint */ public function getLatestIssueInSprint() { $archiveStatusId = IssueStatus::getIdByMachineName('archive'); return $this->issues()->where('status_id', '!=', (int) $archiveStatusId)->orderBy('created_at', 'desc')->first(); }
/** * Get the collection of issues corresponding to a given sprint - that are not archived * @param integer $sprintId * @return collection */ public function getIssuesFromSprint($sprintId) { $archiveStatusId = IssueStatus::getIdByMachineName('archive'); return $this->issues()->where('status_id', '!=', (int) $archiveStatusId)->where('sprint_id', '=', (int) $sprintId)->get(); }
/** * Get issue statuses, except "archive" by sort_order */ public static function getBySortOrder() { return IssueStatus::where('machine_name', '!=', 'archive')->orderBy('sort_order', 'asc')->get(); }