[Fusionforge-commits] r8400 - trunk/gforge/cronjobs

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Nov 18 21:23:34 CET 2009


Author: lolando
Date: 2009-11-18 21:23:34 +0100 (Wed, 18 Nov 2009)
New Revision: 8400

Modified:
   trunk/gforge/cronjobs/site_stats.php
Log:
db_query_params() transition

Modified: trunk/gforge/cronjobs/site_stats.php
===================================================================
--- trunk/gforge/cronjobs/site_stats.php	2009-11-18 20:23:24 UTC (rev 8399)
+++ trunk/gforge/cronjobs/site_stats.php	2009-11-18 20:23:34 UTC (rev 8400)
@@ -62,15 +62,16 @@
 			array ("$year$month",
 				$day));
 $err .= db_error();
-$sql = "INSERT INTO stats_agg_logo_by_group ";
 if ($sys_database_type == 'mysql') {
-	$sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,count(*) AS count";
+	$sql = "INSERT INTO stats_agg_logo_by_group SELECT '$year$month' AS month, '$day' AS newday,group_id,count(*) AS count FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
+	$rel = db_query_mysql ($sql);
 } else {
-	$sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,count(*) AS count";
+	$rel = db_query_params ('INSERT INTO stats_agg_logo_by_group SELECT $1::int AS month, $2::int AS newday,group_id,count(*) AS count
+	FROM activity_log WHERE type=0 AND day=$3 GROUP BY month,newday,group_id',
+				array ("$year$month",
+				       $day,
+				       $yesterday_formatted)) ;
 }
-$sql.="
-	FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
-$rel = db_query($sql);
 $err .= db_error();
 
 
@@ -83,15 +84,18 @@
 			array ("$year$month",
 				$day));
 $err .= db_error();
-$sql = "INSERT INTO stats_agg_site_by_group ";
 if ($sys_database_type == 'mysql') {
+	$sql = "INSERT INTO stats_agg_site_by_group ";
 	$sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,COUNT(*) AS count";
+	$sql .= "
+	FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
+	$rel = db_query_mysql ($sql);
 } else {
-	$sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,COUNT(*) AS count";
+	$rel = db_query_params ('INSERT INTO stats_agg_site_by_group SELECT $1::int AS month, $2::int AS newday,group_id,COUNT(*) AS count FROM activity_log WHERE type=0 AND day=$3 GROUP BY month,newday,group_id',
+				array ("$year$month",
+				       $day,
+				       $yesterday_formatted)) ;
 }
-$sql .= "
-	FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
-$rel = db_query($sql);
 $err .= db_error();
 
 
@@ -103,15 +107,15 @@
 			array ("$year$month",
 				$day));
 $err .= db_error();
-$sql = "INSERT INTO stats_site_pages_by_day (month,day,site_page_views) ";
 if ($sys_database_type == 'mysql') {
-	$sql .= "SELECT '$year$month' AS month, '$day' AS newday, count(*) AS count";
+	$sql = "INSERT INTO stats_site_pages_by_day (month,day,site_page_views) SELECT '$year$month' AS month, '$day' AS newday, count(*) AS count FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday";
+	$rel = db_query_mysql ($sql);
 } else {
-	$sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday, count(*) AS count";
+	$rel = db_query_params ('INSERT INTO stats_site_pages_by_day (month,day,site_page_views) SELECT $1::int AS month, $2::int AS newday, count(*) AS count FROM activity_log WHERE type=0 AND day=$3 GROUP BY month,newday',
+				array ("$year$month",
+				       $day,
+				       $yesterday_formatted)) ;
 }
-$sql .= "
-		FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday";
-$rel = db_query($sql);
 $err .= db_error();
 
 
@@ -123,16 +127,14 @@
 			array ("$year$month",
 				$day));
 $err .= db_error();
-$sql = "INSERT INTO stats_project_developers (month,day,group_id,developers) ";
 if ($sys_database_type == 'mysql') {
-	$sql .= "SELECT '$year$month' AS month,'$day' AS day,group_id,count(*) AS count";
+	$sql = "INSERT INTO stats_project_developers (month,day,group_id,developers) SELECT '$year$month' AS month,'$day' AS day,group_id,count(*) AS count FROM user_group GROUP BY month,day,group_id";
+	$rel = db_query_mysql ($sql);
 } else {
-	$sql .= "SELECT '$year$month'::int AS month,'$day'::int AS day,group_id,count(*) AS count";
+	$rel = db_query_params ('INSERT INTO stats_project_developers (month,day,group_id,developers) SELECT $1::int AS month,$2::int AS day,group_id,count(*) AS count FROM user_group GROUP BY month,day,group_id',
+				array ("$year$month",
+				       $day));
 }
-$sql .= "
-		FROM user_group 
-		GROUP BY month,day,group_id";
-$rel = db_query($sql);
 $err .= db_error();
 
 db_commit();




More information about the Fusionforge-commits mailing list