4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of FusionForge.
8 * FusionForge 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 * FusionForge 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 FusionForge; 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_once $gfcommon.'include/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 $rel = db_query_params ('DELETE FROM stats_agg_logo_by_day WHERE day=$1',
47 array ($yesterday_formatted));
49 $rel = db_query_params ('INSERT INTO stats_agg_logo_by_day
51 FROM activity_log WHERE type=0 AND day=$1 GROUP BY day',
52 array ($yesterday_formatted));
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 $rel = db_query_params ('DELETE FROM stats_agg_logo_by_group WHERE month=$1 AND day=$2',
65 $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
66 FROM activity_log WHERE type=0 AND day=$3 GROUP BY month,newday,group_id',
69 $yesterday_formatted)) ;
74 // site showings by group
75 // new table format 2001-april
77 $err .= "\n\nBeginning stats_agg_site_by_group ".date('Ymd H:i:s',time());
78 $rel = db_query_params ('DELETE FROM stats_agg_site_by_group WHERE month=$1 AND day=$2',
82 $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',
85 $yesterday_formatted)) ;
92 $err .= "\n\nBeginning stats_site_pages_by_day ".date('Ymd H:i:s',time());
93 $rel = db_query_params ('DELETE FROM stats_site_pages_by_day WHERE month=$1 AND day=$2',
97 $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',
100 $yesterday_formatted)) ;
105 // insert the number of developers per project into history table
107 $err .= "\n\nBeginning stats_project_developers ".date('Ymd H:i:s',time());
108 $rel = db_query_params ('DELETE FROM stats_project_developers WHERE month=$1 AND day=$2',
109 array ("$year$month",
113 $rel = db_query_params ('INSERT INTO stats_project_developers (month,day,group_id,developers)
114 SELECT $1::int AS month, $2::int, pfo_role.home_group_id AS group_id, COUNT(DISTINCT(pfo_user_role.user_id)) AS developers FROM pfo_user_role, pfo_role WHERE pfo_user_role.role_id = pfo_role.role_id AND pfo_role.home_group_id IS NOT NULL GROUP BY pfo_role.home_group_id',
115 array ("$year$month",
118 $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',
119 array ("$year$month",
129 // populate stats_site table
131 $err .= "\n\nBeginning stats_site ".date('Ymd H:i:s',time());
132 include('cronjobs/stats_site.inc');
133 site_stats_day($year,$month,$day);
136 // populate stats_project table
138 $err .= "\n\nBeginning stats_project ".date('Ymd H:i:s',time());
139 include('cronjobs/stats_projects.inc');
140 project_stats_day($year,$month,$day);