[Fusionforge-commits] r7997 - in trunk/gforge: cronjobs packaging/cron.d plugins/scmcvs/common

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Aug 27 15:42:09 CEST 2009


Author: lolando
Date: 2009-08-27 15:42:09 +0200 (Thu, 27 Aug 2009)
New Revision: 7997

Added:
   trunk/gforge/cronjobs/generate_scm_snapshots.php
Modified:
   trunk/gforge/cronjobs/gather_scm_stats.php
   trunk/gforge/packaging/cron.d/plugin-scmcvs
   trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php
Log:
Fixed gathering of CVS stats

Modified: trunk/gforge/cronjobs/gather_scm_stats.php
===================================================================
--- trunk/gforge/cronjobs/gather_scm_stats.php	2009-08-27 13:41:57 UTC (rev 7996)
+++ trunk/gforge/cronjobs/gather_scm_stats.php	2009-08-27 13:42:09 UTC (rev 7997)
@@ -46,9 +46,9 @@
 while ($data = db_fetch_array ($res)) {
 	$hook_params = array ('group_id' => $data['group_id'],
 			      'mode' => 'day',
-			      'year' => date ('Y', time () - 43200),
-			      'month' => date ('n', time () - 43200),
-			      'day' => date ('j', time () - 43200)) ;
+			      'year' => date ('Y', time () - 86400),
+			      'month' => date ('n', time () - 86400),
+			      'day' => date ('j', time () - 86400)) ;
 	plugin_hook ('scm_gather_stats', $hook_params) ;
 }
 

Added: trunk/gforge/cronjobs/generate_scm_snapshots.php
===================================================================
--- trunk/gforge/cronjobs/generate_scm_snapshots.php	                        (rev 0)
+++ trunk/gforge/cronjobs/generate_scm_snapshots.php	2009-08-27 13:42:09 UTC (rev 7997)
@@ -0,0 +1,56 @@
+#! /usr/bin/php5 -f
+<?php
+/**
+ * FusionForge source control management
+ *
+ * Copyright 2009, Roland Mas
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+        
+require_once '/usr/share/gforge/www/env.inc.php';
+require_once $gfwww.'include/squal_pre.php';
+require_once $gfcommon.'include/cron_utils.php';
+
+// Plugins subsystem
+require_once $gfcommon.'include/Plugin.class.php' ;
+require_once $gfcommon.'include/PluginManager.class.php' ;
+
+// SCM-specific plugins subsystem
+require_once $gfcommon.'include/SCMPlugin.class.php' ;
+			 
+setup_plugin_manager () ;
+
+$res = db_query_params ('SELECT group_id FROM groups WHERE status=$1 AND use_scm=1 ORDER BY group_id DESC',
+			array ('A')); 
+if (!$res) {
+	$this->setError('Unable to get list of projects using SCM: '.db_error());
+	return false;
+}
+
+while ($data = db_fetch_array ($res)) {
+	$hook_params = array ('group_id' => $data['group_id']) ;
+	plugin_hook ('scm_generate_snapshots', $hook_params) ;
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>


Property changes on: trunk/gforge/cronjobs/generate_scm_snapshots.php
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/gforge/packaging/cron.d/plugin-scmcvs
===================================================================
--- trunk/gforge/packaging/cron.d/plugin-scmcvs	2009-08-27 13:41:57 UTC (rev 7996)
+++ trunk/gforge/packaging/cron.d/plugin-scmcvs	2009-08-27 13:42:09 UTC (rev 7997)
@@ -9,9 +9,3 @@
 
 # Snapshots
 35 2 * * * root [ -x /usr/share/gforge/plugins/scmcvs/cronjobs/snapshots.sh ] && /usr/share/gforge/plugins/scmcvs/cronjobs/snapshots.sh generate > /dev/null 2>&1
-
-# Repositories update (.pl in debian)
-5 * * * * root [ -x /usr/share/gforge/plugins/scmcvs/cronjobs/cvs_dump.pl ] && su -s /bin/sh gforge -c /usr/share/gforge/plugins/scmcvs/cronjobs/cvs_dump.pl > /dev/null 2>&1 && [ -x /usr/share/gforge/plugins/scmcvs/cronjobs/cvs_update.pl ] && /usr/share/gforge/plugins/scmcvs/cronjobs/cvs_update.pl > /dev/null 2>&1
-
-# CVS add/commit Statistics
-45 4 * * * root [ -x /usr/share/gforge/plugins/scmcvs/cronjobs/cvs-stats.pl ] && /usr/share/gforge/plugins/scmcvs/cronjobs/cvs-stats.pl > /dev/null 2>&1

Modified: trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2009-08-27 13:41:57 UTC (rev 7996)
+++ trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2009-08-27 13:42:09 UTC (rev 7997)
@@ -207,9 +207,9 @@
 		if ($params['mode'] == 'day') {
 				db_begin();
 
-				$year = $params ('year') ;
-				$month = $params ('month') ;
-				$day = $params ('day') ;
+				$year = $params ['year'] ;
+				$month = $params ['month'] ;
+				$day = $params ['day'] ;
 				$month_string = sprintf( "%04d%02d", $year, $month );
 				$day_begin = gmmktime( 0, 0, 0, $month, $day, $year);
 				$day_end = $day_begin + 86400;
@@ -231,7 +231,7 @@
 				if (!file_exists($hist_file_path) 
 				    || !is_readable($hist_file_path)
 				    || filesize($hist_file_path) == 0) {
-					echo "No history file\n" ;
+					// echo "No history file\n" ;
 					db_rollback () ;
 					return false ;
 				}
@@ -299,7 +299,7 @@
 				if (!db_query_params ('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
 						      array ($month_string,
 							     $day,
-							     $group_id,
+							     $project->getID(),
 							     $cvs_co,
 							     $cvs_commit,
 							     $cvs_add))) {
@@ -324,7 +324,7 @@
 					if (!db_query_params ('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
 							      array ($month_string,
 								     $day,
-								     $group_id,
+								     $project->getID(),
 								     $user_id,
 								     $usr_commit{$user} ? $usr_commit{$user} : 0,
 								     $usr_add{$user} ? $usr_add{$user} : 0))) {




More information about the Fusionforge-commits mailing list