/usr/share/gforge/cronjobs/db_project_sums.php is in gforge-db-postgresql 5.1.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | #! /usr/bin/php
<?php
/**
* Portions Copyright 1999-2001 (c) VA Linux Systems
* The rest Copyright 2002-2004 (c) GForge Team
* http://fusionforge.org/
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation; either version 2 of the Licence, or (at your option)
* any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FusionForge; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require (dirname(__FILE__).'/../www/env.inc.php');
require_once $gfcommon.'include/pre.php';
require $gfcommon.'include/cron_utils.php';
$err='';
/*
Aggregation script
Since we cannot crunch down all the data on the fly anymore,
we need to crunch it down once daily into a separate table,
then join against that table to get counts.
*/
/*
Create an aggregation table that includes counts of forum messages
*/
if (forge_get_config('use_forum')) {
db_begin();
db_query_params ('LOCK TABLE forum_agg_msg_count IN ACCESS EXCLUSIVE MODE',
array()) ;
db_query_params ('LOCK TABLE forum IN ACCESS EXCLUSIVE MODE',
array()) ;
db_query_params ('LOCK TABLE forum_group_list IN ACCESS EXCLUSIVE MODE',
array()) ;
$res = db_query_params ('DELETE FROM forum_agg_msg_count',
array()) ;
if (!$res) {
$err .= "DELETE FROM forum_agg_msg_count : ".db_error();
}
$res = db_query_params ('INSERT INTO forum_agg_msg_count
SELECT fgl.group_forum_id,count(f.msg_id)
FROM forum_group_list fgl
LEFT JOIN forum f USING (group_forum_id)
GROUP BY fgl.group_forum_id',
array()) ;
if (!$res) {
$err .= "INSERT INTO forum_agg_msg_count : ".db_error();
}
db_commit();
}
/*
Create an aggregation table that includes counts of artifacts
*/
if (forge_get_config('use_tracker')) {
db_begin();
db_query_params ('LOCK TABLE artifact_counts_agg IN ACCESS EXCLUSIVE MODE',
array()) ;
db_query_params ('LOCK TABLE artifact IN ACCESS EXCLUSIVE MODE',
array()) ;
db_query_params ('LOCK TABLE artifact_group_list IN ACCESS EXCLUSIVE MODE',
array()) ;
$rel = db_query_params ('DELETE FROM artifact_counts_agg',
array()) ;
$err .= db_error();
$rel=db_query_params ('INSERT INTO artifact_counts_agg
SELECT agl.group_artifact_id,
(SELECT count(*) FROM artifact WHERE status_id <> 3 AND group_artifact_id=agl.group_artifact_id),
(SELECT count(*) FROM artifact WHERE status_id=1 AND group_artifact_id=agl.group_artifact_id)
FROM artifact_group_list agl
LEFT JOIN artifact a USING (group_artifact_id)
GROUP BY agl.group_artifact_id',
array()) ;
$err .= db_error();
db_commit();
}
/*
Rebuild the project_sums_agg table, which saves us
from doing really expensive queries
each time the project summary is viewed
*/
db_begin();
$res=db_query_params ('DELETE FROM project_sums_agg',
array()) ;
/*
Get counts of mailing lists
*/
if (forge_get_config('use_mail')) {
$res=db_query_params ('INSERT INTO project_sums_agg
SELECT group_id,$1 AS type,count(*) AS count
FROM mail_group_list WHERE is_public = 1
GROUP BY group_id,type',
array('mail'));
$err .= db_error();
}
/*
Get counts of surveys
*/
if (forge_get_config('use_survey')) {
$res=db_query_params ('INSERT INTO project_sums_agg
SELECT group_id,$1 AS type,count(*) AS count
FROM surveys
WHERE is_active=$2
GROUP BY group_id,type',
array('surv',
'1'));
$err .= db_error();
}
/*
Forum message count
*/
if (forge_get_config('use_forum')) {
$res=db_query_params ('INSERT INTO project_sums_agg
SELECT forum_group_list.group_id,$1 AS type, count(forum.msg_id) AS count
FROM forum,forum_group_list
WHERE forum.group_forum_id=forum_group_list.group_forum_id
AND forum_group_list.is_public=1
GROUP BY group_id,type',
array('fmsg'));
$err .= db_error();
/*
Forum count
*/
$res=db_query_params ('INSERT INTO project_sums_agg
SELECT group_id,$1 AS type, count(*) AS count
FROM forum_group_list
WHERE is_public=1
GROUP BY group_id,type',
array('fora'));
$err .= db_error();
}
db_commit();
$err .= db_error();
cron_entry(3,$err);
?>
|