? usage/cvs.txt
? usage/dif
? usage/project_usage.api.php
cvs diff: Diffing usage
Index: usage/project_usage.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/usage/project_usage.module,v
retrieving revision 1.32
diff -u -p -r1.32 project_usage.module
--- usage/project_usage.module	17 Mar 2009 23:16:13 -0000	1.32
+++ usage/project_usage.module	11 Apr 2009 21:43:40 -0000
@@ -169,3 +169,62 @@ function project_usage_project_page_link
   }
 }
 
+/**
+ * Return the total usage data for a given project across all versions.
+ *
+ * @param $nid
+ *   The project node ID.
+ *
+ * @return
+ *   The total reported usage for all versions of the given project.
+ */
+function project_usage_get_project_total_usage($nid) {
+  $active_tids = project_release_compatibility_list();
+  static $total = array();
+  if (empty($total[$nid])) {
+    $total[$nid] = 0;
+    foreach ($active_tids as $tid => $term_name) {
+      $total[$nid] += project_usage_get_project_usage($nid, $tid);
+    }
+  }
+  return $total[$nid];
+}
+
+/**
+ * Return usage data for a given API version of a project.
+ *
+ * @param $nid
+ *   The project node ID.
+ * @param $tid
+ *   The API compatibility taxonomy term ID to get usage for.
+ *
+ * @return
+ *   The total reported usage for the given version of the given project.
+ */
+function project_usage_get_project_usage($nid, $tid) {
+  static $usage = array();
+  module_load_include('inc', 'project_usage', 'includes/date_api');
+  if (empty($usage[$nid][$tid])) {
+    $usage[$nid][$tid] = db_result(db_query("SELECT count FROM {project_usage_week_project} WHERE nid = %d AND tid = %d AND timestamp = %d", $nid, $tid, project_usage_get_current_active_week()));
+  }
+  return $usage[$nid][$tid];
+}
+
+/**
+ * Return usage data for a given release.
+ *
+ * @param $nid
+ *   The release node ID.
+ *
+ * @return
+ *   The total reported usage for the given release.
+ */
+function project_usage_get_release_usage($nid) {
+  static $usage = array();
+  module_load_include('inc', 'project_usage', 'includes/date_api');
+  if (empty($usage[$nid])) {
+    $usage[$nid] = db_result(db_query("SELECT count FROM {project_usage_week_release} WHERE nid = %d AND timestamp = %d", $nid, project_usage_get_current_active_week()));
+  }
+  return $usage[$nid];
+}
+
cvs diff: Diffing usage/includes
Index: usage/includes/date_api.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/usage/includes/date_api.inc,v
retrieving revision 1.1
diff -u -p -r1.1 date_api.inc
--- usage/includes/date_api.inc	17 Mar 2009 23:16:13 -0000	1.1
+++ usage/includes/date_api.inc	11 Apr 2009 21:43:40 -0000
@@ -109,6 +109,14 @@ function project_usage_get_active_weeks(
   return $weeks;
 }
 
+function project_usage_get_current_active_week() {
+  static $current_week = 0;
+  if (empty($current_week)) {
+    $current_week = array_shift(project_usage_get_active_weeks());
+  }
+  return $current_week;
+}
+
 /**
  * Sets the expiry timestamp for cached project usage pages.
  *
cvs diff: Diffing usage/tests
