5 * Provides access to various GForge statistics.
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge 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
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 class Stats extends Error {
27 * Stats - Stats object constructor
35 * Returns a resultset consisting of the month, day, total_users, pageviews, and sessions
36 * from the stats_site tables
38 * @return a resultset of month, day, total_users, pageviews, sessions
40 function getSiteStats() {
41 $res = db_query("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");
43 $this->setError('Unable to get stats: '.db_error());
50 * Returns a result set containing the group_name, unix_group_name, group_id, ranking, and percentile
51 * for either the last week or for all time
53 * @param type week or null (for all time)
54 * @param offset used to page thru the result
55 * @return a resultset of group_name, unix_group_name, group_id, ranking, percentile
57 function getMostActiveStats($type, $offset) {
59 if ($type == 'week') {
60 $sql="SELECT groups.group_name,groups.unix_group_name,groups.group_id,project_weekly_metric.ranking,project_weekly_metric.percentile ".
61 "FROM groups,project_weekly_metric ".
62 "WHERE groups.group_id=project_weekly_metric.group_id AND ".
63 "groups.is_public=1 ".
64 "ORDER BY ranking ASC";
66 $sql="SELECT g.group_name,g.unix_group_name,g.group_id,s.group_ranking as ranking,s.group_metric as percentile ".
67 "FROM groups g,stats_project_all_vw s ".
68 "WHERE g.group_id=s.group_id ".
69 "AND g.is_public=1 and s.group_ranking > 0 ".
70 "ORDER BY ranking ASC";
72 //return db_query($sql, $LIMIT, $offset);
73 return db_query($sql, 0, $offset);
77 * Returns a resultset containing unix_group_name, group_name, and items - the count of
78 * the messages posted on that group's forums
80 * @return a resultset of unix_group_name, group_name, items
82 function getTopMessagesPosted() {
83 return db_query("select g.unix_group_name, g.group_name, sum(s.msg_posted) as items "
84 ." from stats_project s, groups g "
85 ." where s.group_id = g.group_id "
86 ." and g.is_public=1 "
88 ." group by g.unix_group_name, g.group_name "
89 ." order by items desc", 100);
93 * Returns a resultset containing group_name, unix_group_name, and items - the count of
94 * the page views for that group
96 * @return a resultset of group_name, unix_group_name, items
98 function getTopPageViews() {
99 return db_query("select g.group_name, g.unix_group_name, sum(s.page_views) as items "
100 ." from stats_project_months s, groups g "
101 ." where s.group_id = g.group_id "
102 ." and g.is_public=1 "
103 ." and g.status='A' "
104 ." group by g.group_name, g.unix_group_name "
105 ." order by items desc", 100);
109 * Returns a resultset containing group_name, unix_group_name, and items - the count of
110 * the downloads for that group
112 * @return a resultset of group_name, unix_group_name, items
114 function getTopDownloads() {
115 return db_query("select g.group_name, g.unix_group_name, sum(frs.downloads) as items "
116 ." from frs_dlstats_grouptotal_vw frs, groups g "
117 ." where g.group_id = frs.group_id "
118 ." and g.status='A' "
119 ." and g.is_public='1' "
120 ." group by g.group_name, g.unix_group_name "
121 ." order by items desc", 100);