[Fusionforge-commits] r8817 - in trunk/gforge/plugins: scmbzr/common scmgit/common scmsvn/common

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Feb 12 16:49:37 CET 2010


Author: lolando
Date: 2010-02-12 16:49:36 +0100 (Fri, 12 Feb 2010)
New Revision: 8817

Modified:
   trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
   trunk/gforge/plugins/scmgit/common/GitPlugin.class.php
   trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php
Log:
Made SCM stats gathering faster (much faster, in the case of SVN)

Modified: trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2010-02-12 12:11:46 UTC (rev 8816)
+++ trunk/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2010-02-12 15:49:36 UTC (rev 8817)
@@ -334,17 +334,19 @@
 			}
                         
                         // inserting group results in stats_cvs_groups
-                        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,
-                                                     $project->getID(),
-                                                     0,
-                                                     $updates,
-                                                     $adds))) {
-                                echo "Error while inserting into stats_cvs_group\n" ;
-                                db_rollback () ;
-                                return false ;
-                        }
+			if ($updates > 0 || $adds > 0) {
+				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,
+							     $project->getID(),
+							     0,
+							     $updates,
+							     $adds))) {
+					echo "Error while inserting into stats_cvs_group\n" ;
+					db_rollback () ;
+					return false ;
+				}
+			}
                                 
                         // building the user list
                         $user_list = array_unique( array_merge( array_keys( $usr_adds ), array_keys( $usr_updates ) ) );
@@ -357,18 +359,22 @@
                                 } else {
                                         continue;
                                 }
-                                        
-                                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,
-                                                             $project->getID(),
-                                                             $user_id,
-                                                             $usr_updates[$user] ? $usr_updates[$user] : 0,
-                                                             $usr_adds[$user] ? $usr_adds[$user] : 0))) {
-                                        echo "Error while inserting into stats_cvs_user\n" ;
-                                       db_rollback () ;
-                                        return false ;
-                                }
+				
+				$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
+				$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
+				if ($uu > 0 || $ua > 0) {
+					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,
+								     $project->getID(),
+								     $user_id,
+								     $uu,
+								     $ua))) {
+						echo "Error while inserting into stats_cvs_user\n" ;
+						db_rollback () ;
+						return false ;
+					}
+				}
                         }
                 }
                 db_commit();

Modified: trunk/gforge/plugins/scmgit/common/GitPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmgit/common/GitPlugin.class.php	2010-02-12 12:11:46 UTC (rev 8816)
+++ trunk/gforge/plugins/scmgit/common/GitPlugin.class.php	2010-02-12 15:49:36 UTC (rev 8817)
@@ -403,16 +403,18 @@
 			}
 
 			// inserting group results in stats_cvs_groups
-			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,
-						     $project->getID(),
-						     0,
-						     $updates,
-						     $adds))) {
-				echo "Error while inserting into stats_cvs_group\n" ;
-				db_rollback () ;
-				return false ;
+			if ($updates > 0 || $adds > 0) {
+				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,
+							     $project->getID(),
+							     0,
+							     $updates,
+							     $adds))) {
+					echo "Error while inserting into stats_cvs_group\n" ;
+					db_rollback () ;
+					return false ;
+				}
 			}
 				
 			// building the user list
@@ -427,16 +429,20 @@
 					continue;
 				}
 					
-				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,
-							     $project->getID(),
-							     $user_id,
-							     $usr_updates[$user] ? $usr_updates[$user] : 0,
-							     $usr_adds[$user] ? $usr_adds[$user] : 0))) {
-					echo "Error while inserting into stats_cvs_user\n" ;
-					db_rollback () ;
-					return false ;
+				$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
+				$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
+				if ($uu > 0 || $ua > 0) {
+					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,
+								     $project->getID(),
+								     $user_id,
+								     $uu,
+								     $ua))) {
+						echo "Error while inserting into stats_cvs_user\n" ;
+						db_rollback () ;
+						return false ;
+					}
 				}
 			}
 		}

Modified: trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2010-02-12 12:11:46 UTC (rev 8816)
+++ trunk/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2010-02-12 15:49:36 UTC (rev 8817)
@@ -304,8 +304,11 @@
 				return false ;
 			}
 	
-			$pipe = popen ("svn log file://$repo --xml -v -q 2> /dev/null", 'r' ) ;
+                        $d1 = date ('Y-m-d', $start_time - 150000) ;
+                        $d2 = date ('Y-m-d', $end_time + 150000) ;
 
+			$pipe = popen ("svn log file://$repo --xml -v -q -r '".'{'.$d2.'}:{'.$d1.'}'."' 2> /dev/null", 'r' ) ;
+
 			// cleaning stats_cvs_* table for the current day
 			$res = db_query_params ('DELETE FROM stats_cvs_group WHERE month=$1 AND day=$2 AND group_id=$3',
 						array ($month_string,
@@ -345,7 +348,7 @@
 					break;
 				}
 
-				if (!$time_ok && $last_time && $last_time < $start_time) {
+				if (!$time_ok && $last_time && $last_time > $end_time) {
 					break;
 				}
 			}
@@ -353,16 +356,18 @@
 			xml_parser_free ($xml_parser);
 
 			// inserting group results in stats_cvs_groups
-			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,
-						     $project->getID(),
-						     0,
-						     $updates,
-						     $adds))) {
-				echo "Error while inserting into stats_cvs_group\n" ;
-				db_rollback () ;
-				return false ;
+			if ($updates > 0 || $adds > 0) {
+				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,
+							     $project->getID(),
+							     0,
+							     $updates,
+							     $adds))) {
+					echo "Error while inserting into stats_cvs_group\n" ;
+					db_rollback () ;
+					return false ;
+				}
 			}
 				
 			// building the user list
@@ -376,17 +381,21 @@
 				} else {
 					continue;
 				}
-					
-				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,
-							     $project->getID(),
-							     $user_id,
-							     $usr_updates[$user] ? $usr_updates[$user] : 0,
-							     $usr_adds[$user] ? $usr_adds[$user] : 0))) {
-					echo "Error while inserting into stats_cvs_user\n" ;
-					db_rollback () ;
-					return false ;
+		
+				$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
+				$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
+				if ($uu > 0 || $ua > 0) {
+					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,
+								     $project->getID(),
+								     $user_id,
+								     $uu,
+								     $ua))) {
+						echo "Error while inserting into stats_cvs_user\n" ;
+						db_rollback () ;
+						return false ;
+					}
 				}
 			}
 		}




More information about the Fusionforge-commits mailing list