Completed
Pull Request — master (#526)
by Michael
16:45 queued 06:57
created

StatsFastCloses   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPageTitle() 0 3 1
A requiresWikiDatabase() 0 3 1
A getPageName() 0 3 1
A execute() 0 36 1
A isProtected() 0 3 1
1
<?php
2
/**************************************************************************
3
**********      English Wikipedia Account Request Interface      **********
4
***************************************************************************
5
** Wikipedia Account Request Graphic Design by Charles Melbye,           **
6
** which is licensed under a Creative Commons                            **
7
** Attribution-Noncommercial-Share Alike 3.0 United States License.      **
8
**                                                                       **
9
** All other code are released under the Public Domain                   **
10
** by the ACC Development Team.                                          **
11
**                                                                       **
12
** See CREDITS for the list of developers.                               **
13
***************************************************************************/
14
15
class StatsFastCloses extends StatisticsPage
16
{
17
	protected function execute()
18
	{
19
		$query = <<<SQL
20
SELECT
21
  log_closed.objectid AS Request,
22
  user.username AS User,
23
  log_closed.user AS UserID,
24
  TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) AS 'Time Taken',
25
  closes.mail_desc AS 'Close Type',
26
  log_closed.timestamp AS 'Date'
27
28
FROM log log_closed
29
INNER JOIN log log_reserved ON log_closed.objectid = log_reserved.objectid 
30
	AND log_closed.objecttype = log_reserved.objecttype
31
INNER JOIN closes ON closes.`closes` = log_closed.action
32
LEFT JOIN user ON log_closed.user = user.id
33
34
WHERE log_closed.action LIKE 'Closed%'
35
  AND log_reserved.action = 'Reserved'
36
  AND TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) < '00:00:30'
37
  AND log_closed.user = log_reserved.user
38
  AND TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) > '00:00:00'
39
  AND DATE(log_closed.timestamp) > DATE(NOW()-INTERVAL 3 MONTH)
40
41
ORDER BY TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) ASC
42
;
43
SQL;
44
45
		$qb = new QueryBrowser();
46
		$qb->tableCallbackFunction = "statsFastClosesRowCallback";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'statsFastClosesRowCallback' of type string is incompatible with the declared type boolean|callable of property $tableCallbackFunction.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
		$qb->overrideTableTitles =
48
			array("Request", "User", "Time Taken", "Close Type", "Date");
49
		$qb->rowFetchMode = PDO::FETCH_NUM;
50
		$r = $qb->executeQueryToTable($query);
51
52
		return $r;
53
	}
54
55
	public function getPageName()
56
	{
57
		return "FastCloses";
58
	}
59
60
	public function getPageTitle()
61
	{
62
		return "Requests closed less than 30 seconds after reservation in the past 3 months";
63
	}
64
65
	public function isProtected()
66
	{
67
		return true;
68
	}
69
70
	public function requiresWikiDatabase()
71
	{
72
		return false;
73
	}
74
}
75
76
function statsFastClosesRowCallback($row, $currentreq)
0 ignored issues
show
Unused Code introduced by
The parameter $currentreq is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

76
function statsFastClosesRowCallback($row, /** @scrutinizer ignore-unused */ $currentreq)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
77
{
78
	$out = '<tr>';
79
80
	global $baseurl;
81
82
	$rowCount = count($row);
83
84
	for ($colid = 0; $colid < $rowCount; $colid++) {
85
		$cell = $row[$colid];
86
87
		$out .= "<td>";
88
89
		if ($colid == 0) {
90
			$out .= "<a href=\"" . $baseurl . "/acc.php?action=zoom&id=" . $cell . "\">";
91
		}
92
		if ($colid == 1) {
93
			$out .= "<a href=\"" . $baseurl . "/statistics.php/Users?user=" . $row[++$colid] . "\">";
94
		}
95
96
		$out .= $cell;
97
98
		if ($colid == 0 || $colid == 2) {
99
			$out .= "</a>"; // colid is now 2 if triggered from above due to postinc
100
		}
101
102
		$out .= "</td>";
103
	}
104
105
	$out .= "</tr>";
106
107
	return $out;
108
}
109