Here's an initial patch for 2.x that adds some initial support for Sampler module that allows tracking the commits per repository over time (typically defaults to 1 week).

I'm also planning to add support for a metric of total commits across all repos, and possibly another metric for total committers by repository and another for total committers across all repositories.

Comments

marvil07’s picture

Status: Needs review » Needs work

I have not really used sampler module yet, but I have some general comments:

diff --git a/metrics/VersionControlMetric.class.php b/metrics/VersionControlMetric.class.php

We have an includes/ directory, where we store e.g. all versioncontrol related ctools plugins, all views handlers, all our classes, etc. I guess this is also a better place to store sampler ctools plugins.

+++ b/metrics/VersionControlMetric.class.php
@@ -0,0 +1,32 @@
+    $repos = db_query("SELECT DISTINCT(vcr.repo_id) FROM {versioncontrol_repositories} vcr INNER JOIN {versioncontrol_operations} vco ON vcr.repo_id = vco.repo_id");

Why do we need a join if we are making a distinct?

If you are trying to get all repositories, it's safe to use only the repository table, and there you do not need a distinct.

+++ b/metrics/VersionControlNewCommitsByRepository.class.php
@@ -0,0 +1,44 @@
+    $commits = db_query_slave("SELECT vco.repo_id, COUNT(vco.vc_op_id) AS count FROM {versioncontrol_operations} vco  WHERE vco.date >= %d AND vco.date < %d$where GROUP BY vco.repo_id", $args);

The operations table does not longer have a date column, instead we have now author_date and committer_date, see #1054436: Store commit date and authoring date for details.

mikey_p’s picture

Status: Needs work » Needs review
StatusFileSize
new7.13 KB

New patch with better comments, adds total commits as well as new commits for each repository and also globally in a separate metric.

marvil07’s picture

Status: Needs review » Needs work

All comments in 1 are still valid.

mikey_p’s picture

Sorry I cross-posted without seeing your comment first (hence the -1 in my patch name). This is unfortunate since I'm doing all my testing against the d.o database and it seems to be running a rather outdated version of Versioncontrol (from November 23th, 2011 or something like that).

I can re-roll the patch here against the latest changes in Versioncontrol module for now but I'd love to know if there's an issue about getting the latest changes onto d.o.

mikey_p’s picture

Had a conversation with sdboyer and marvil07 in IRC and the consensus seems to be that we really need to tie into the new events system that fire the first time an event is received to ensure that commits are counted even if they are pushed much later than their commit date, or even their authoring date.

I think I've laid out the basics for adding sampler support and I'd love to have someone that has better understanding of Versioncontrol's internals (especially the new event system) finish this up.

More examples of sampler plugins can be found at:
http://drupalcode.org/project/project_issue.git/tree/refs/heads/6.x-1.x:...
http://drupalcode.org/project/sampler.git/tree/refs/heads/6.x-1.x:/metrics

And if any other question arrive hunmonk has said that he is somewhat available to help folks writing sampler plugins.

marvil07’s picture

Priority: Normal » Major

During triage.

dww’s picture

Issue tags: +project metrics, +metrics, +Drupal.org 7.1

Just marked #1961824: Add a commits stats mini-graph in the "Statistics (2 years)" section of projects. duplicate. Adding some tags to help me find this again. ;) The Drupal.org 7.1 tag is for things that are a reasonably high priority as soon as we launch D7, which I believe this should be.

marvil07’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Category: task » feature

Moving to d7

tvn’s picture

Priority: Major » Normal
tvn’s picture

Issue summary: View changes
Issue tags: -Drupal.org 7.1

Untagging, as this is not an immediate regression. Would be good to implement for the future though.

marvil07’s picture

Issue tags: +Needs issue summary update

Not sure how metrics expects interaction(i.e. re-sample), but now that we have "event processor" plugins it seems like the place to trigger this.