4 * Portions Copyright 1999-2001 (c) VA Linux Systems
5 * The rest Copyright 2002-2004 (c) GForge Team
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 USA
25 require (dirname(__FILE__).'/../www/env.inc.php');
26 require_once $gfwww.'include/pre.php';
27 require $gfcommon.'include/cron_utils.php';
35 Since we cannot crunch down all the data on the fly anymore,
36 we need to crunch it down once daily into a separate table,
37 then join against that table to get counts.
43 Create an aggregation table that includes counts of forum messages
45 if (forge_get_config('use_forum')) {
48 db_query_params ('LOCK TABLE forum_agg_msg_count IN ACCESS EXCLUSIVE MODE',
50 db_query_params ('LOCK TABLE forum IN ACCESS EXCLUSIVE MODE',
52 db_query_params ('LOCK TABLE forum_group_list IN ACCESS EXCLUSIVE MODE',
55 $res = db_query_params ('DELETE FROM forum_agg_msg_count',
59 $err .= "DELETE FROM forum_agg_msg_count : ".db_error();
62 $res = db_query_params ('INSERT INTO forum_agg_msg_count
63 SELECT fgl.group_forum_id,count(f.msg_id)
64 FROM forum_group_list fgl
65 LEFT JOIN forum f USING (group_forum_id)
66 GROUP BY fgl.group_forum_id',
70 $err .= "INSERT INTO forum_agg_msg_count : ".db_error();
77 Create an aggregation table that includes counts of artifacts
79 if (forge_get_config('use_tracker')) {
82 db_query_params ('LOCK TABLE artifact_counts_agg IN ACCESS EXCLUSIVE MODE',
84 db_query_params ('LOCK TABLE artifact IN ACCESS EXCLUSIVE MODE',
86 db_query_params ('LOCK TABLE artifact_group_list IN ACCESS EXCLUSIVE MODE',
89 $rel = db_query_params ('DELETE FROM artifact_counts_agg',
94 $rel=db_query_params ('INSERT INTO artifact_counts_agg
95 SELECT agl.group_artifact_id,
96 (SELECT count(*) FROM artifact WHERE status_id <> 3 AND group_artifact_id=agl.group_artifact_id),
97 (SELECT count(*) FROM artifact WHERE status_id=1 AND group_artifact_id=agl.group_artifact_id)
98 FROM artifact_group_list agl
99 LEFT JOIN artifact a USING (group_artifact_id)
100 GROUP BY agl.group_artifact_id',
110 Rebuild the project_sums_agg table, which saves us
111 from doing really expensive queries
112 each time the project summary is viewed
116 $res=db_query_params ('DELETE FROM project_sums_agg',
120 Get counts of mailing lists
122 if (forge_get_config('use_mail')) {
123 $res=db_query_params ('INSERT INTO project_sums_agg
124 SELECT group_id,$1 AS type,count(*) AS count
125 FROM mail_group_list WHERE is_public = 1
126 GROUP BY group_id,type',
132 Get counts of surveys
134 if (forge_get_config('use_survey')) {
135 $res=db_query_params ('INSERT INTO project_sums_agg
136 SELECT group_id,$1 AS type,count(*) AS count
139 GROUP BY group_id,type',
149 if (forge_get_config('use_forum')) {
150 $res=db_query_params ('INSERT INTO project_sums_agg
151 SELECT forum_group_list.group_id,$1 AS type, count(forum.msg_id) AS count
152 FROM forum,forum_group_list
153 WHERE forum.group_forum_id=forum_group_list.group_forum_id
154 AND forum_group_list.is_public=1
155 GROUP BY group_id,type',
162 $res=db_query_params ('INSERT INTO project_sums_agg
163 SELECT group_id,$1 AS type, count(*) AS count
164 FROM forum_group_list
166 GROUP BY group_id,type',