File: Stats.class

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (122 lines) | stat: -rw-r--r-- 4,223 bytes parent folder | download | duplicates (3)
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
<?php   
/**
 *	Stats object
 *
 *	Provides access to various GForge statistics.
 *
 * This file is part of GForge.
 *
 * GForge 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 License, or
 * (at your option) any later version.
 *
 * GForge 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 GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

class Stats extends Error {

	/**
	 *	Stats - Stats object constructor
	 */
	function Stats() {
		$this->Error();
		return true;
	}

	/**
	* Returns a resultset consisting of the month, day, total_users, pageviews, and sessions
	* from the stats_site tables
	*
	* @return a resultset of month, day, total_users, pageviews, sessions
	*/
	function getSiteStats() {
		$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");
		if (!$res) {
			$this->setError('Unable to get stats: '.db_error());
			return false;
		}
		return $res;
	}

	/**
	* Returns a result set containing the group_name, unix_group_name, group_id, ranking, and percentile
	* for either the last week or for all time
	*
	* @param type	week or null (for all time)
	*	@param offset	used to page thru the result
	* @return a resultset of group_name, unix_group_name, group_id, ranking, percentile
	*/
	function getMostActiveStats($type, $offset) {
		$sql="";
		if ($type == 'week') 	{
		  $sql="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.is_public=1 ".
		    "ORDER BY ranking ASC";
		} else {
			$sql="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.is_public=1 and s.group_ranking > 0 ".
			"ORDER BY ranking ASC";
		}
		return db_query($sql, $LIMIT, $offset);
	}

	/**
	* Returns a resultset containing unix_group_name, group_name, and items - the count of
	* the messages posted on that group's forums
	*
	* @return a resultset of unix_group_name, group_name, items
	*/
	function getTopMessagesPosted() {
		return db_query("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.is_public=1 "
	." and g.status='A' "
	." group by g.unix_group_name, g.group_name "
	." order by items desc", 100);
	}

	/**
	* Returns a resultset containing group_name, unix_group_name, and items - the count of
	* the page views for that group
	*
	* @return a resultset of group_name, unix_group_name, items
	*/
	function getTopPageViews() {
		return db_query("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.is_public=1 "
			." and g.status='A' "
			." group by g.group_name, g.unix_group_name "
			." order by items desc", 100);
	}
	
	/**
	* Returns a resultset containing group_name, unix_group_name, and items - the count of
	* the downloads for that group
	*
	* @return a resultset of group_name, unix_group_name, items
	*/
	function getTopDownloads() {
		return db_query("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='A' "
			." and g.is_public='1' "
			." group by g.group_name, g.unix_group_name "
			." order by items desc", 100);
	}
}