/** * fiches analyzed dont BI non renseignes * fiches analyzed dont RAE non renseignes * @return ConsistencyError[] */ public function checkAnalyzed() { // CoDev FDJ custom, defined in Mantis $status_analyzed = Config::getVariableKeyFromValue(Config::id_statusNames, 'analyzed'); $status_accepted = Config::getVariableKeyFromValue(Config::id_statusNames, 'accepted'); $status_deferred = Config::getVariableKeyFromValue(Config::id_statusNames, 'deferred'); $FDJ_teamid = Config::getInstance()->getValue(Config::id_ClientTeamid); $cerrList = array(); // select all issues which current status is 'analyzed' $query = "SELECT * " . "FROM `mantis_bug_table` " . "WHERE status in ({$status_analyzed}, {$status_accepted}, " . Constants::$status_open . ", {$status_deferred}) "; if (0 != count($this->projectList)) { $formatedProjects = implode(', ', array_keys($this->projectList)); $query .= "AND project_id IN ({$formatedProjects}) "; } $query .= "ORDER BY last_updated DESC, bug_id DESC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $issue = IssueCache::getInstance()->getIssue($row->id, $row); if (NULL == $issue->getEffortEstim()) { $cerr = new ConsistencyError($row->id, $row->handler_id, $row->status, $row->last_updated, T_("BI not specified: BI = Time(Analysis + Dev + Tests)")); $cerr->severity = T_("Error"); $cerrList[] = $cerr; } if (is_null($issue->getBacklog())) { $cerr = new ConsistencyError($row->bug_id, $row->handler_id, $row->status, $row->last_updated, T_("Backlog not specified: Backlog = Time(BI - Analysis)")); $cerr->severity = T_("Error"); $cerrList[] = $cerr; } if ($status_analyzed == $row->status) { $user = UserCache::getInstance()->getUser($row->handler_id); if (!$user->isTeamMember($FDJ_teamid)) { $cerr = new ConsistencyError($row->bug_id, $row->handler_id, $row->status, $row->last_updated, T_("Once analysed, a Task must be assigned to 'FDJ' for validation")); $cerr->severity = T_("Error"); $cerrList[] = $cerr; } } } // check if fields correctly set return $cerrList; }
/** * Feedback is special: it must be separated in two groups: * - feedback assigned to 'ATOS' * - feedback assigned to 'FDJ' * @return number[] */ private function getDuration_feedback() { // FDJ custom status (not defined in Mantis) $status_feedback_ATOS = Config::getVariableKeyFromValue(Config::id_statusNames, 'feedback_ATOS'); $status_feedback_FDJ = Config::getVariableKeyFromValue(Config::id_statusNames, 'feedback_FDJ'); $FDJ_teamid = Config::getInstance()->getValue(Config::id_ClientTeamid); $time_atos = 0; $time_fdj = 0; $current_date = time(); // the start_date is transition where new_value = status // the end_date is transition where old_value = status, or current date if no transition found. // Find start_date $query = "SELECT id, date_modified, old_value, new_value " . "FROM `mantis_bug_history_table` " . "WHERE bug_id={$this->bugId} " . "AND field_name = 'status' " . "AND (new_value=" . Constants::$status_feedback . " OR old_value=" . Constants::$status_feedback . ") " . "ORDER BY id ASC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $start_date = $row->date_modified; $start_id = $row->id; // Next line is end_date. if NULL then end_date = current_date if ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) { $end_date = $row->date_modified; $end_id = $row->id; $sql_condition = " AND id <= '{$end_id}'"; } else { $end_date = $current_date; $end_id = $start_id; // easy way to check if feedback is the current status $sql_condition = ""; } $intervale = $end_date - $start_date; //echo "STATUS start_id = $start_id end_id = $end_id <br/>"; // Determinate to whom it was assigned // find the last handler_id change before $end_id $query2 = "SELECT id, date_modified, old_value, new_value " . "FROM `mantis_bug_history_table` " . "WHERE bug_id={$this->bugId} " . "AND field_name='handler_id' " . $sql_condition . " ORDER BY id DESC"; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } // the list is in reverse order so the first one is the latest assignment. $row2 = SqlWrapper::getInstance()->sql_fetch_object($result2); $handler_id = $row2->new_value; $latest_assignTo_id = $row2->id; $latest_assignTo_date = $row2->date_modified; $previous_handler_id = $row2->old_value; //echo "latest assign id = $latest_assignTo_id date=$latest_assignTo_date handler_id=$handler_id<br/>"; // If 'feedback' is NOT the current status if ($end_id > $start_id) { // REM: // the problem is that if the user changes status and assigned_to at the same // time, the 'assigned to' action is logged before the 'change status'. // => the latest 'assigned to' action belongs to the future 'change status' action. // so if the next action is a 'change status' and the date is the same than the 'assigned to' // action, THEN we must take the previous 'assigned to' action in the list. // Get the next action to check if it is a 'change status' $query3 = "SELECT id, date_modified, field_name FROM `mantis_bug_history_table` WHERE bug_id={$this->bugId} AND id > '{$latest_assignTo_id}' ORDER BY id ASC"; $result3 = SqlWrapper::getInstance()->sql_query($query3); if (!$result3) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } $row3 = SqlWrapper::getInstance()->sql_fetch_object($result3); $next_action_date = $row3->date_modified; $next_action_field = $row3->field_name; //echo "next action id = $row3->id date=$next_action_date field=$next_action_field<br/>"; if ($next_action_date == $latest_assignTo_date && $next_action_field == "status") { // we want the previous assigned_to (note: the $result2 is order by DESC) //echo "we want previous assign<br/>"; $handler_id = $row2->old_value; //$row2 = SqlWrapper::getInstance()->sql_fetch_object($result2); //echo "previous assign id = $row2->id date=$row2->date_modified handler_id=$handler_id <br/>"; } } $user1 = UserCache::getInstance()->getUser($handler_id); if ($user1->isTeamDeveloper($FDJ_teamid)) { //echo "user $handler_id is FDJ (team $FDJ_teamid)<br/>"; $time_fdj = $time_fdj + $intervale; } else { //echo "user $handler_id is ATOS<br/>"; $time_atos = $time_atos + $intervale; } } $formatedDateList = array(); $formatedDateList[$status_feedback_ATOS] = $time_atos; $formatedDateList[$status_feedback_FDJ] = $time_fdj; return $formatedDateList; }