|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\Pages\Statistics; |
|
10
|
|
|
|
|
11
|
|
|
use Waca\Tasks\InternalPageBase; |
|
12
|
|
|
|
|
13
|
|
|
class StatsMain extends InternalPageBase |
|
14
|
|
|
{ |
|
15
|
|
|
public function main() |
|
16
|
|
|
{ |
|
17
|
|
|
$this->setHtmlTitle('Statistics'); |
|
18
|
|
|
|
|
19
|
|
|
$this->assign('statsPageTitle', 'Account Creation Statistics'); |
|
20
|
|
|
|
|
21
|
|
|
$statsPages = array( |
|
22
|
|
|
'fastCloses' => 'Requests closed less than 30 seconds after reservation in the past 3 months', |
|
23
|
|
|
'inactiveUsers' => 'Inactive tool users', |
|
24
|
|
|
'monthlyStats' => 'Monthly Statistics', |
|
25
|
|
|
'reservedRequests' => 'All currently reserved requests', |
|
26
|
|
|
'templateStats' => 'Template Stats', |
|
27
|
|
|
'topCreators' => 'Top Account Creators', |
|
28
|
|
|
'users' => 'Account Creation Tool users', |
|
29
|
|
|
); |
|
30
|
|
|
|
|
31
|
|
|
$this->generateSmallStatsTable(); |
|
32
|
|
|
|
|
33
|
|
|
$this->assign('statsPages', $statsPages); |
|
34
|
|
|
|
|
35
|
|
|
$graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month'); |
|
36
|
|
|
$this->assign('graphList', $graphList); |
|
37
|
|
|
|
|
38
|
|
|
$this->setTemplate('statistics/main.tpl'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Gets the relevant statistics from the database for the small statistics table |
|
43
|
|
|
*/ |
|
44
|
|
|
private function generateSmallStatsTable() |
|
45
|
|
|
{ |
|
46
|
|
|
$database = $this->getDatabase(); |
|
47
|
|
|
$requestsQuery = <<<'SQL' |
|
48
|
|
|
SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed'; |
|
49
|
|
|
SQL; |
|
50
|
|
|
$requestsStatement = $database->prepare($requestsQuery); |
|
51
|
|
|
|
|
52
|
|
|
$requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
53
|
|
|
|
|
54
|
|
|
$requestStateData = array(); |
|
55
|
|
|
|
|
56
|
|
|
foreach ($requestStates as $statusName => $data) { |
|
57
|
|
|
$requestsStatement->execute(array(':status' => $statusName)); |
|
58
|
|
|
$requestCount = $requestsStatement->fetchColumn(); |
|
59
|
|
|
$requestsStatement->closeCursor(); |
|
60
|
|
|
$headerText = $data['header']; |
|
61
|
|
|
$requestStateData[$headerText] = $requestCount; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$this->assign('requestCountData', $requestStateData); |
|
65
|
|
|
|
|
66
|
|
|
// Unconfirmed requests |
|
67
|
|
|
$unconfirmedStatement = $database->query(<<<SQL |
|
68
|
|
|
SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != ''; |
|
69
|
|
|
SQL |
|
70
|
|
|
); |
|
71
|
|
|
$unconfirmed = $unconfirmedStatement->fetchColumn(); |
|
72
|
|
|
$unconfirmedStatement->closeCursor(); |
|
73
|
|
|
$this->assign('statsUnconfirmed', $unconfirmed); |
|
74
|
|
|
|
|
75
|
|
|
$userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;'); |
|
76
|
|
|
|
|
77
|
|
|
// Admin users |
|
78
|
|
|
$userStatusStatement->execute(array(':status' => 'Admin')); |
|
79
|
|
|
$adminUsers = $userStatusStatement->fetchColumn(); |
|
80
|
|
|
$userStatusStatement->closeCursor(); |
|
81
|
|
|
$this->assign('statsAdminUsers', $adminUsers); |
|
82
|
|
|
|
|
83
|
|
|
// Users |
|
84
|
|
|
$userStatusStatement->execute(array(':status' => 'User')); |
|
85
|
|
|
$users = $userStatusStatement->fetchColumn(); |
|
86
|
|
|
$userStatusStatement->closeCursor(); |
|
87
|
|
|
$this->assign('statsUsers', $users); |
|
88
|
|
|
|
|
89
|
|
|
// Suspended users |
|
90
|
|
|
$userStatusStatement->execute(array(':status' => 'Suspended')); |
|
91
|
|
|
$suspendedUsers = $userStatusStatement->fetchColumn(); |
|
92
|
|
|
$userStatusStatement->closeCursor(); |
|
93
|
|
|
$this->assign('statsSuspendedUsers', $suspendedUsers); |
|
94
|
|
|
|
|
95
|
|
|
// New users |
|
96
|
|
|
$userStatusStatement->execute(array(':status' => 'New')); |
|
97
|
|
|
$newUsers = $userStatusStatement->fetchColumn(); |
|
98
|
|
|
$userStatusStatement->closeCursor(); |
|
99
|
|
|
$this->assign('statsNewUsers', $newUsers); |
|
100
|
|
|
|
|
101
|
|
|
// Most comments on a request |
|
102
|
|
|
$mostCommentsStatement = $database->query(<<<SQL |
|
103
|
|
|
SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1; |
|
104
|
|
|
SQL |
|
105
|
|
|
); |
|
106
|
|
|
$mostComments = $mostCommentsStatement->fetchColumn(); |
|
107
|
|
|
$mostCommentsStatement->closeCursor(); |
|
108
|
|
|
$this->assign('mostComments', $mostComments); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|