4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of GForge.
8 * GForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * GForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
23 require dirname(__FILE__).'/../www/env.inc.php';
24 require $gfwww.'include/squal_pre.php';
25 require $gfcommon.'include/cron_utils.php';
31 $how_far_back=(time() - 86400);
33 $yesterday_formatted=date('Ymd',$how_far_back);
35 $year=date('Y', $how_far_back);
36 $month=date('m', $how_far_back);
37 $day=date('d', $how_far_back);
38 $day_begin=mktime(0,0,0,$month,$day,$year);
39 $day_end=($day_begin + 86400);
43 // logo showings by day
45 $err .= "\n\nBeginning stats_agg_logo_by_day ".date('Ymd H:i:s',time());
46 $sql = "DELETE FROM stats_agg_logo_by_day WHERE day='$yesterday_formatted'";
47 $rel = db_query($sql);
49 $sql = "INSERT INTO stats_agg_logo_by_day
51 FROM activity_log WHERE type=1 AND day='$yesterday_formatted' GROUP BY day";
52 $rel = db_query($sql);
57 // logo showings by group
58 // new table format 2001-april
60 $err .= "\n\nBeginning stats_agg_logo_by_group ".date('Ymd H:i:s',time());
61 $sql = "DELETE FROM stats_agg_logo_by_group WHERE month='$year$month' AND day='$day'";
62 $rel = db_query($sql);
64 $sql = "INSERT INTO stats_agg_logo_by_group ";
65 if ($sys_database_type == 'mysql') {
66 $sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,count(*) AS count";
68 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,count(*) AS count";
71 FROM activity_log WHERE type=1 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
72 $rel = db_query($sql);
77 // site showings by group
78 // new table format 2001-april
80 $err .= "\n\nBeginning stats_agg_site_by_group ".date('Ymd H:i:s',time());
81 $sql = "DELETE FROM stats_agg_site_by_group WHERE month='$year$month' AND day='$day'";
82 $rel = db_query($sql);
84 $sql = "INSERT INTO stats_agg_site_by_group ";
85 if ($sys_database_type == 'mysql') {
86 $sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,COUNT(*) AS count";
88 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,COUNT(*) AS count";
91 FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
92 $rel = db_query($sql);
99 $err .= "\n\nBeginning stats_site_pages_by_day ".date('Ymd H:i:s',time());
100 $sql = "DELETE FROM stats_site_pages_by_day WHERE month='$year$month' AND day='$day'";
101 $rel = db_query($sql);
103 $sql = "INSERT INTO stats_site_pages_by_day (month,day,site_page_views) ";
104 if ($sys_database_type == 'mysql') {
105 $sql .= "SELECT '$year$month' AS month, '$day' AS newday, count(*) AS count";
107 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday, count(*) AS count";
110 FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday";
111 $rel = db_query($sql);
116 // insert the number of developers per project into history table
118 $err .= "\n\nBeginning stats_project_developers ".date('Ymd H:i:s',time());
119 $rel=db_query("DELETE FROM stats_project_developers WHERE month='$year$month' AND day='$day'");
121 $sql = "INSERT INTO stats_project_developers (month,day,group_id,developers) ";
122 if ($sys_database_type == 'mysql') {
123 $sql .= "SELECT '$year$month' AS month,'$day' AS day,group_id,count(*) AS count";
125 $sql .= "SELECT '$year$month'::int AS month,'$day'::int AS day,group_id,count(*) AS count";
129 GROUP BY month,day,group_id";
130 $rel = db_query($sql);
138 // populate stats_site table
140 $err .= "\n\nBeginning stats_site ".date('Ymd H:i:s',time());
141 include('cronjobs/stats_site.inc');
142 site_stats_day($year,$month,$day);
145 // populate stats_project table
147 $err .= "\n\nBeginning stats_project ".date('Ymd H:i:s',time());
148 include('cronjobs/stats_projects.inc');
149 project_stats_day($year,$month,$day);