4 * Copyright 1999-2001 (c) VA Linux Systems
8 * This file is part of GForge.
10 * GForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * GForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with GForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
25 require ('squal_pre.php');
26 require ('common/include/cron_utils.php');
32 $how_far_back=(time() - 86400);
34 $yesterday_formatted=date('Ymd',$how_far_back);
36 $year=date('Y', $how_far_back);
37 $month=date('m', $how_far_back);
38 $day=date('d', $how_far_back);
39 $day_begin=mktime(0,0,0,$month,$day,$year);
40 $day_end=($day_begin + 86400);
44 // logo showings by day
46 $err .= "\n\nBeginning stats_agg_logo_by_day ".date('Ymd H:i:s',time());
47 $sql = "DELETE FROM stats_agg_logo_by_day WHERE day='$yesterday_formatted'";
48 $rel = db_query($sql);
50 $sql = "INSERT INTO stats_agg_logo_by_day
52 FROM activity_log WHERE type=1 AND day='$yesterday_formatted' GROUP BY day";
53 $rel = db_query($sql);
58 // logo showings by group
59 // new table format 2001-april
61 $err .= "\n\nBeginning stats_agg_logo_by_group ".date('Ymd H:i:s',time());
62 $sql = "DELETE FROM stats_agg_logo_by_group WHERE month='$year$month' AND day='$day'";
63 $rel = db_query($sql);
65 $sql = "INSERT INTO stats_agg_logo_by_group ";
66 if ($sys_database_type == "mysql") {
67 $sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,count(*) AS count";
69 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,count(*) AS count";
72 FROM activity_log WHERE type=1 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
73 $rel = db_query($sql);
78 // site showings by group
79 // new table format 2001-april
81 $err .= "\n\nBeginning stats_agg_site_by_group ".date('Ymd H:i:s',time());
82 $sql = "DELETE FROM stats_agg_site_by_group WHERE month='$year$month' AND day='$day'";
83 $rel = db_query($sql);
85 $sql = "INSERT INTO stats_agg_site_by_group ";
86 if ($sys_database_type == "mysql") {
87 $sql .= "SELECT '$year$month' AS month, '$day' AS newday,group_id,COUNT(*) AS count";
89 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday,group_id,COUNT(*) AS count";
92 FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday,group_id";
93 $rel = db_query($sql);
100 $err .= "\n\nBeginning stats_site_pages_by_day ".date('Ymd H:i:s',time());
101 $sql = "DELETE FROM stats_site_pages_by_day WHERE month='$year$month' AND day='$day'";
102 $rel = db_query($sql);
104 $sql = "INSERT INTO stats_site_pages_by_day (month,day,site_page_views) ";
105 if ($sys_database_type == "mysql") {
106 $sql .= "SELECT '$year$month' AS month, '$day' AS newday, count(*) AS count";
108 $sql .= "SELECT '$year$month'::int AS month, '$day'::int AS newday, count(*) AS count";
111 FROM activity_log WHERE type=0 AND day='$yesterday_formatted' GROUP BY month,newday";
112 $rel = db_query($sql);
117 // insert the number of developers per project into history table
119 $err .= "\n\nBeginning stats_project_developers ".date('Ymd H:i:s',time());
120 $rel=db_query("DELETE FROM stats_project_developers WHERE month='$year$month' AND day='$day'");
122 $sql = "INSERT INTO stats_project_developers (month,day,group_id,developers) ";
123 if ($sys_database_type == "mysql") {
124 $sql .= "SELECT '$year$month' AS month,'$day' AS day,group_id,count(*) AS count";
126 $sql .= "SELECT '$year$month'::int AS month,'$day'::int AS day,group_id,count(*) AS count";
130 GROUP BY month,day,group_id";
131 $rel = db_query($sql);
139 // populate stats_site table
141 $err .= "\n\nBeginning stats_site ".date('Ymd H:i:s',time());
142 include('cronjobs/stats_site.inc');
143 site_stats_day($year,$month,$day);
146 // populate stats_project table
148 $err .= "\n\nBeginning stats_project ".date('Ymd H:i:s',time());
149 include('cronjobs/stats_projects.inc');
150 project_stats_day($year,$month,$day);