4 * Portions Copyright 1999-2001 (c) VA Linux Systems
5 * The rest Copyright 2002-2004 (c) GForge Team
6 * http://fusionforge.org/
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require (dirname(__FILE__).'/../www/env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require $gfcommon.'include/cron_utils.php';
34 Since we cannot crunch down all the data on the fly anymore,
35 we need to crunch it down once daily into a separate table,
36 then join against that table to get counts.
42 Create an aggregation table that includes counts of forum messages
44 if (forge_get_config('use_forum')) {
47 db_query_params ('LOCK TABLE forum_agg_msg_count IN ACCESS EXCLUSIVE MODE',
49 db_query_params ('LOCK TABLE forum IN ACCESS EXCLUSIVE MODE',
51 db_query_params ('LOCK TABLE forum_group_list IN ACCESS EXCLUSIVE MODE',
54 $res = db_query_params ('DELETE FROM forum_agg_msg_count',
58 $err .= "DELETE FROM forum_agg_msg_count : ".db_error();
61 $res = db_query_params ('INSERT INTO forum_agg_msg_count
62 SELECT fgl.group_forum_id,count(f.msg_id)
63 FROM forum_group_list fgl
64 LEFT JOIN forum f USING (group_forum_id)
65 GROUP BY fgl.group_forum_id',
69 $err .= "INSERT INTO forum_agg_msg_count : ".db_error();
76 Create an aggregation table that includes counts of artifacts
78 if (forge_get_config('use_tracker')) {
81 db_query_params ('LOCK TABLE artifact_counts_agg IN ACCESS EXCLUSIVE MODE',
83 db_query_params ('LOCK TABLE artifact IN ACCESS EXCLUSIVE MODE',
85 db_query_params ('LOCK TABLE artifact_group_list IN ACCESS EXCLUSIVE MODE',
88 $rel = db_query_params ('DELETE FROM artifact_counts_agg',
93 $rel=db_query_params ('INSERT INTO artifact_counts_agg
94 SELECT agl.group_artifact_id,
95 (SELECT count(*) FROM artifact WHERE status_id <> 3 AND group_artifact_id=agl.group_artifact_id),
96 (SELECT count(*) FROM artifact WHERE status_id=1 AND group_artifact_id=agl.group_artifact_id)
97 FROM artifact_group_list agl
98 LEFT JOIN artifact a USING (group_artifact_id)
99 GROUP BY agl.group_artifact_id',
109 Rebuild the project_sums_agg table, which saves us
110 from doing really expensive queries
111 each time the project summary is viewed
115 $res=db_query_params ('DELETE FROM project_sums_agg',
119 Get counts of mailing lists
121 if (forge_get_config('use_mail')) {
122 $res=db_query_params ('INSERT INTO project_sums_agg
123 SELECT group_id,$1 AS type,count(*) AS count
124 FROM mail_group_list WHERE is_public = 1
125 GROUP BY group_id,type',
131 Get counts of surveys
133 if (forge_get_config('use_survey')) {
134 $res=db_query_params ('INSERT INTO project_sums_agg
135 SELECT group_id,$1 AS type,count(*) AS count
138 GROUP BY group_id,type',
148 if (forge_get_config('use_forum')) {
149 $res=db_query_params ('INSERT INTO project_sums_agg
150 SELECT forum_group_list.group_id,$1 AS type, count(forum.msg_id) AS count
151 FROM forum,forum_group_list
152 WHERE forum.group_forum_id=forum_group_list.group_forum_id
153 AND forum_group_list.is_public=1
154 GROUP BY group_id,type',
161 $res=db_query_params ('INSERT INTO project_sums_agg
162 SELECT group_id,$1 AS type, count(*) AS count
163 FROM forum_group_list
165 GROUP BY group_id,type',