4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 require dirname(__FILE__).'/../www/env.inc.php';
23 require_once $gfcommon.'include/pre.php';
24 require $gfcommon.'include/cron_utils.php';
30 $how_far_back=(time() - 86400);
32 $yesterday_formatted=date('Ymd',$how_far_back);
34 $year=date('Y', $how_far_back);
35 $month=date('m', $how_far_back);
36 $day=date('d', $how_far_back);
37 $day_begin=mktime(0,0,0,$month,$day,$year);
38 $day_end=($day_begin + 86400);
42 // logo showings by day
44 $err .= "\n\nBeginning stats_agg_logo_by_day ".date('Ymd H:i:s',time());
45 $rel = db_query_params ('DELETE FROM stats_agg_logo_by_day WHERE day=$1',
46 array ($yesterday_formatted));
48 $rel = db_query_params ('INSERT INTO stats_agg_logo_by_day
50 FROM activity_log WHERE type=0 AND day=$1 GROUP BY day',
51 array ($yesterday_formatted));
56 // logo showings by group
57 // new table format 2001-april
59 $err .= "\n\nBeginning stats_agg_logo_by_group ".date('Ymd H:i:s',time());
60 $rel = db_query_params ('DELETE FROM stats_agg_logo_by_group WHERE month=$1 AND day=$2',
64 $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
65 FROM activity_log WHERE type=0 AND day=$3 GROUP BY month,newday,group_id',
68 $yesterday_formatted)) ;
73 // site showings by group
74 // new table format 2001-april
76 $err .= "\n\nBeginning stats_agg_site_by_group ".date('Ymd H:i:s',time());
77 $rel = db_query_params ('DELETE FROM stats_agg_site_by_group WHERE month=$1 AND day=$2',
81 $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',
84 $yesterday_formatted)) ;
91 $err .= "\n\nBeginning stats_site_pages_by_day ".date('Ymd H:i:s',time());
92 $rel = db_query_params ('DELETE FROM stats_site_pages_by_day WHERE month=$1 AND day=$2',
96 $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',
99 $yesterday_formatted)) ;
104 // insert the number of developers per project into history table
106 $err .= "\n\nBeginning stats_project_developers ".date('Ymd H:i:s',time());
107 $rel = db_query_params ('DELETE FROM stats_project_developers WHERE month=$1 AND day=$2',
108 array ("$year$month",
111 $rel = db_query_params ('INSERT INTO stats_project_developers (month,day,group_id,developers)
112 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',
113 array ("$year$month",
122 // populate stats_site table
124 $err .= "\n\nBeginning stats_site ".date('Ymd H:i:s',time());
125 include 'cronjobs/stats_site.inc';
126 site_stats_day($year,$month,$day);
129 // populate stats_project table
131 $err .= "\n\nBeginning stats_project ".date('Ymd H:i:s',time());
132 include 'cronjobs/stats_projects.inc';
133 project_stats_day($year,$month,$day);