3 * FusionForge statistics
5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2002, GForge, LLC
7 * Copyright 2009, Roland Mas
9 * Thorsten Glaser <t.glaser@tarent.de>
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 class Stats extends FFError {
30 * Returns a resultset consisting of the month, day, total_users, pageviews, and sessions
31 * from the stats_site tables
33 * @return resource A resultset of month, day, total_users, pageviews, sessions
35 function getSiteStats() {
36 $res = db_query_params ("select byday.month,byday.day,byday.site_page_views as pageviews, ss.total_users, ss.sessions from stats_site_pages_by_day byday, stats_site ss where byday.month=ss.month and byday.day = ss.day order by byday.month asc, byday.day asc",
39 $this->setError('Unable to get stats: '.db_error());
46 * Returns a result set containing the group_name, unix_group_name, group_id, ranking, and percentile
47 * for either the last week or for all time
49 * @param string $type week or null (for all time)
50 * @param int $offset used to page thru the result
51 * @return resource A resultset of group_name, unix_group_name, group_id, ranking, percentile
53 function getMostActiveStats($type, $offset) {
54 if ($type == 'week') {
55 return db_query_params('SELECT groups.group_name,groups.unix_group_name,groups.group_id,project_weekly_metric.ranking,project_weekly_metric.percentile FROM groups,project_weekly_metric WHERE groups.group_id=project_weekly_metric.group_id AND groups.status = $1 AND groups.use_stats=1 ORDER BY ranking ASC',
60 return db_query_params('SELECT g.group_name,g.unix_group_name,g.group_id,s.group_ranking as ranking,s.group_metric as percentile
61 FROM groups g,stats_project_all_vw s
62 WHERE g.group_id=s.group_id
65 AND s.group_ranking > 0
66 ORDER BY ranking ASC',
74 * Returns a resultset containing unix_group_name, group_name, and items - the count of
75 * the messages posted on that group's forums
77 * @return resource a resultset of unix_group_name, group_name, items
79 function getTopMessagesPosted() {
80 return db_query_params ('SELECT g.unix_group_name, g.group_name, SUM(s.msg_posted) AS items, g.group_id FROM stats_project s, groups g WHERE s.group_id=g.group_id AND g.status=$1 GROUP BY g.unix_group_name, g.group_name, g.group_id ORDER BY items DESC',
86 * Returns a resultset containing group_name, unix_group_name, and items - the count of
87 * the page views for that group
89 * @return resource a resultset of group_name, unix_group_name, items
91 function getTopPageViews() {
92 return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(s.page_views) AS items, g.group_id FROM stats_project_months s, groups g WHERE s.group_id=g.group_id AND g.status=$1 GROUP BY g.group_name, g.unix_group_name, g.group_id ORDER BY items DESC',
98 * Returns a resultset containing group_name, unix_group_name, and items - the count of
99 * the downloads for that group
101 * @return resource a resultset of group_name, unix_group_name, items
103 function getTopDownloads() {
104 return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(frs.downloads) AS items, g.group_id FROM frs_dlstats_grouptotal_vw frs, groups g WHERE g.group_id = frs.group_id AND g.status=$1 GROUP BY g.group_name, g.unix_group_name, g.group_id ORDER BY items DESC',
112 // c-file-style: "bsd"