public function computeSample()
 {
     // Load options.
     $options = $this->currentSample->options;
     // Initialize the projects array.
     $data_types = $this->newProjectOpenedVsClosed();
     $this->projectIssueMetricInitProjects($data_types);
     $where_pieces = array();
     $args = array();
     $where_args = array();
     // The initial arguments are the 'open' project issue status options.
     $open_states = project_issue_state(0, FALSE, FALSE, 0, TRUE);
     // TODO: Until http://drupal.org/node/214347 is resolved, we don't want
     // the 'fixed' status in the list of open statuses, so unset it here.
     unset($open_states[PROJECT_ISSUE_STATE_FIXED]);
     $open_states = array_keys($open_states);
     $args = array_merge($args, $open_states);
     // Restrict to only the passed nids.
     if (!empty($options['object_ids'])) {
         $where_pieces[] = "pid IN (" . db_placeholders($options['object_ids']) . ")";
         $where_args = array_merge($where_args, $options['object_ids']);
     }
     if (empty($where_pieces)) {
         $where = '';
     } else {
         $where = ' AND ' . implode(' AND ', $where_pieces);
         $args = array_merge($args, $where_args);
     }
     // Use the historical calculation if requested.
     if (isset($options['historical']) && $options['historical'] == '1') {
         $this->buildSampleResultsHistorical($open_states, $where, $where_args);
     } else {
         // Build total open issues counts.
         $this->buildSampleResultsCurrent('open', $open_states, $where, $args);
         // Build total closed issues counts.
         $this->buildSampleResultsCurrent('closed', $open_states, $where, $args);
     }
     // Add in total counts across all categories.
     foreach ($this->currentSample->values as $project_id => $values_array) {
         $this->currentSample->values[$project_id]['total_open'] = $values_array['bug_open'] + $values_array['feature_open'] + $values_array['task_open'] + $values_array['support_open'];
         $this->currentSample->values[$project_id]['total_closed'] = $values_array['bug_closed'] + $values_array['feature_closed'] + $values_array['task_closed'] + $values_array['support_closed'];
     }
 }
 public function computeSample()
 {
     // Load options.
     $options = $this->currentSample->options;
     $where_pieces = array();
     $args = array();
     // The initial arguments are the 'open' project issue status options.
     $open_states = project_issue_state(0, FALSE, FALSE, 0, TRUE);
     // TODO: Until http://drupal.org/node/214347 is resolved, we don't want
     // the 'fixed' status in the list of open statuses, so unset it here.
     unset($open_states[PROJECT_ISSUE_STATE_FIXED]);
     $open_states = array_keys($open_states);
     $args = array_merge($args, $open_states);
     // Don't compute if we're on the first sample in a sample set.
     if (!$this->getPreviousSample()) {
         return FALSE;
     }
     // Restrict to only the passed nids.
     if (!empty($options['object_ids'])) {
         $where_pieces[] = "pid IN (" . db_placeholders($options['object_ids']) . ")";
         $args = array_merge($args, $options['object_ids']);
     }
     if (empty($where_pieces)) {
         $where = '';
     } else {
         $where = ' AND ' . implode(' AND ', $where_pieces);
     }
     // Build total open issues counts.
     $this->buildSampleResults('open', $open_states, $where, $args);
     // Build total closed issues counts.
     $this->buildSampleResults('closed', $open_states, $where, $args);
     // Add in total counts across all categories.
     foreach ($this->currentSample->values as $project_id => $values_array) {
         $this->currentSample->values[$project_id]['total_open'] = $values_array['bug_open'] + $values_array['feature_open'] + $values_array['task_open'] + $values_array['support_open'];
         $this->currentSample->values[$project_id]['total_closed'] = $values_array['bug_closed'] + $values_array['feature_closed'] + $values_array['task_closed'] + $values_array['support_closed'];
     }
 }