3 * FusionForge statistics
5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2002, GForge, LLC
7 * Copyright 2009, Roland Mas
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge 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 along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 class Stats extends Error {
28 * Stats - Stats object constructor
36 * Returns a resultset consisting of the month, day, total_users, pageviews, and sessions
37 * from the stats_site tables
39 * @return a resultset of month, day, total_users, pageviews, sessions
41 function getSiteStats() {
42 $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",
45 $this->setError('Unable to get stats: '.db_error());
52 * Returns a result set containing the group_name, unix_group_name, group_id, ranking, and percentile
53 * for either the last week or for all time
55 * @param type week or null (for all time)
56 * @param offset used to page thru the result
57 * @return a resultset of group_name, unix_group_name, group_id, ranking, percentile
59 function getMostActiveStats($type, $offset) {
60 if ($type == 'week') {
61 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.type_id=1 AND groups.status = $1 AND groups.use_stats=1 ORDER BY ranking ASC',
66 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 FROM groups g,stats_project_all_vw s WHERE g.group_id=s.group_id AND g.type_id=1 AND g.status = $1 AND g.use_stats=1 AND s.group_ranking > 0 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 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 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 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 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 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 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 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 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 ORDER BY items DESC',
112 // c-file-style: "bsd"