=== added file 'sites/all/modules/project_issue/metrics/ProjectIssueNewIssuesCommentsByProject.class.php'
--- sites/all/modules/project_issue/metrics/ProjectIssueNewIssuesCommentsByProject.class.php	1970-01-01 00:00:00 +0000
+++ sites/all/modules/project_issue/metrics/ProjectIssueNewIssuesCommentsByProject.class.php	2010-10-01 18:11:50 +0000
@@ -0,0 +1,63 @@
+<?php
+
+// $Id: $
+
+/**
+ * @file
+ * Class for new_issues_comments_by_project metric.
+ */
+
+class  ProjectIssueNewIssuesCommentsByProject extends SamplerMetric {
+
+  public function computeSample() {
+
+    // Load options.
+    $sample = $this->currentSample;
+
+    $where_pieces = array();
+    $args = array();
+
+    $args = array_merge($args, array($sample->sample_startstamp, $sample->sample_endstamp));
+
+    // Restrict to only the passed projects.
+    if (!empty($sample->options['object_ids'])) {
+      $where_pieces[] = "pi.pid IN (". db_placeholders($sample->options['object_ids']) .")";
+      $args = array_merge($args, $sample->options['object_ids']);
+    }
+
+    if (empty($where_pieces)) {
+      $where = '';
+    }
+    else {
+      $where = ' AND ' . implode(' AND ', $where_pieces);
+    }
+
+    // Pull the count of new issues per project.  Since projects may have had
+    // no new issues created during the sample period, we have to join against
+    // the {project_projects} table in order to account for them all.
+    // TODO: this query is *really* expensive -- would be nice to optimize it
+    // some more...
+    $projects = db_query("SELECT pp.nid, COUNT(pi.nid) AS count FROM {project_projects} pp LEFT JOIN {project_issues} pi ON pp.nid = pi.pid LEFT JOIN {node} n ON pi.nid = n.nid WHERE (n.created IS NULL OR (n.created > %d AND n.created < %d))$where GROUP BY pp.nid", $args);
+
+    while ($project = db_fetch_object($projects)) {
+      // Provide a zero starting value for number of comments, and an initial
+      // total.
+      $this->currentSample->values[$project->nid] = array(
+        'new_issues' => $project->count,
+        'new_comments' => 0,
+        'new_total' => $project->count,
+      );
+    }
+
+    // Pull the count of new issue comments per project -- this query will
+    // miss any projects that don't have issue comments, but we've already
+    // provided a zero starting value above in this case.
+    $projects = db_query("SELECT pi.pid, COUNT(pi.cid) AS count FROM {project_issue_comments} pi WHERE pi.timestamp > %d AND pi.timestamp < %d$where GROUP BY pi.pid", $args);
+
+    while ($project = db_fetch_object($projects)) {
+      $this->currentSample->values[$project->pid]['new_comments'] = $project->count;
+      // Add the comment count to the total.
+      $this->currentSample->values[$project->pid]['new_total'] = $this->currentSample->values[$project->pid]['new_total'] + $project->count;
+    }
+  }
+}
\ No newline at end of file

=== added file 'sites/all/modules/project_issue/metrics/new_issues_comments_by_project.inc'
--- sites/all/modules/project_issue/metrics/new_issues_comments_by_project.inc	1970-01-01 00:00:00 +0000
+++ sites/all/modules/project_issue/metrics/new_issues_comments_by_project.inc	2010-10-01 17:35:43 +0000
@@ -0,0 +1,31 @@
+<?php
+
+// $Id$
+
+/**
+ * @file
+ * Metric plugin for counting the number of new issues and comments.
+ *
+ * This metric is intended to by used with the periodic method plugin.
+ *
+ * Values are calculated per project.  The totals for new issues, new comments,
+ * and a sum total of both are calculated.
+ *
+ * This metric accepts the following options:
+ * - object_ids:
+ *     An array of nids. If passed it will restrict the results to nodes in
+ *     this list.
+ */
+
+$plugin = array(
+  'title' => t('New issues and comments by project'),
+  'description' => t("Counts the total number of new issues and new comments for each project in a period of time."),
+  'data_type' => array(
+    'new_issues' => 'int',
+    'new_comments' => 'int',
+    'new_total' => 'int',
+  ),
+  'handler' => array(
+    'class' => 'ProjectIssueNewIssuesCommentsByProject',
+  ),
+);
\ No newline at end of file

