@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | $username = $request->query->get('username'); |
64 | 64 | |
65 | 65 | if (($project || $queryProject) && $username) { |
66 | - $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ]; |
|
66 | + $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username]; |
|
67 | 67 | return $this->redirectToRoute("EditCounterResult", $routeParams); |
68 | 68 | } elseif (!$project && $queryProject) { |
69 | - return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]); |
|
69 | + return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->init($project); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | 'rev_small' => $revisionCounts['small'], |
172 | 172 | 'rev_large' => $revisionCounts['large'], |
173 | 173 | 'with_comments' => $revisionCounts['with_comments'], |
174 | - 'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'], |
|
174 | + 'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'], |
|
175 | 175 | 'minor_edits' => $revisionCounts['minor_edits'], |
176 | - 'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'], |
|
176 | + 'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'], |
|
177 | 177 | 'auto_edits_total' => array_sum($automatedEditsSummary), |
178 | 178 | |
179 | 179 | // Page counts. |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getUserId($usernameOrIp) |
37 | 37 | { |
38 | - $cacheKey = 'userid.' . $usernameOrIp; |
|
38 | + $cacheKey = 'userid.'.$usernameOrIp; |
|
39 | 39 | if ($this->cacheHas($cacheKey)) { |
40 | 40 | return $cacheKey; |
41 | 41 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $topEditCounts = []; |
62 | 62 | foreach ($this->labsHelper->allProjects() as $project) { |
63 | - $cacheKey = 'topprojects.' . $project['dbName'] . '.' . $username; |
|
63 | + $cacheKey = 'topprojects.'.$project['dbName'].'.'.$username; |
|
64 | 64 | if ($this->cacheHas($cacheKey)) { |
65 | 65 | $total = $this->cacheGet($cacheKey); |
66 | 66 | } else { |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } |
77 | 77 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
78 | 78 | } |
79 | - uasort($topEditCounts, function ($a, $b) { |
|
80 | - return $b['total'] - $a['total']; |
|
79 | + uasort($topEditCounts, function($a, $b) { |
|
80 | + return $b['total']-$a['total']; |
|
81 | 81 | }); |
82 | 82 | return array_slice($topEditCounts, 0, $numProjects); |
83 | 83 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | $revisionCounts = array_combine( |
150 | - array_map(function ($e) { |
|
150 | + array_map(function($e) { |
|
151 | 151 | return $e['source']; |
152 | 152 | }, $results), |
153 | - array_map(function ($e) { |
|
153 | + array_map(function($e) { |
|
154 | 154 | return $e['value']; |
155 | 155 | }, $results) |
156 | 156 | ); |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | // Count the number of days, accounting for when there's zero or one edit. |
159 | 159 | $revisionCounts['days'] = 0; |
160 | 160 | if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) { |
161 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); |
|
162 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; |
|
161 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); |
|
162 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Format the first and last dates. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | : 0; |
172 | 172 | |
173 | 173 | // Sum deleted and live to make the total. |
174 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; |
|
174 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; |
|
175 | 175 | |
176 | 176 | // Calculate the average number of live edits per day. |
177 | 177 | $revisionCounts['avg_per_day'] = round( |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | $results = $resultQuery->fetchAll(); |
216 | 216 | |
217 | 217 | $pageCounts = array_combine( |
218 | - array_map(function ($e) { |
|
218 | + array_map(function($e) { |
|
219 | 219 | return $e['source']; |
220 | 220 | }, $results), |
221 | - array_map(function ($e) { |
|
221 | + array_map(function($e) { |
|
222 | 222 | return $e['value']; |
223 | 223 | }, $results) |
224 | 224 | ); |
225 | 225 | |
226 | 226 | // Total created. |
227 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; |
|
227 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; |
|
228 | 228 | |
229 | 229 | // Calculate the average number of edits per page. |
230 | 230 | $pageCounts['edits_per_page'] = 0; |
@@ -253,17 +253,17 @@ discard block |
||
253 | 253 | $resultQuery->execute(); |
254 | 254 | $results = $resultQuery->fetchAll(); |
255 | 255 | $logCounts = array_combine( |
256 | - array_map(function ($e) { |
|
256 | + array_map(function($e) { |
|
257 | 257 | return $e['source']; |
258 | 258 | }, $results), |
259 | - array_map(function ($e) { |
|
259 | + array_map(function($e) { |
|
260 | 260 | return $e['value']; |
261 | 261 | }, $results) |
262 | 262 | ); |
263 | 263 | |
264 | 264 | // Make sure there is some value for each of the wanted counts. |
265 | 265 | $requiredCounts = [ |
266 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', |
|
266 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', |
|
267 | 267 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', |
268 | 268 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', |
269 | 269 | ]; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | // Merge approvals together. |
277 | - $logCounts['review-approve'] = $logCounts['review-approve'] + |
|
278 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
279 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
277 | + $logCounts['review-approve'] = $logCounts['review-approve']+ |
|
278 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
279 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
280 | 280 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
281 | 281 | |
282 | 282 | // Add Commons upload count, if applicable. |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | { |
303 | 303 | $userId = $this->getUserId($username); |
304 | 304 | $sql = "SELECT page_namespace, count(rev_id) AS total |
305 | - FROM ".$this->labsHelper->getTable('revision') ." r |
|
305 | + FROM ".$this->labsHelper->getTable('revision')." r |
|
306 | 306 | JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
307 | 307 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
308 | 308 | $resultQuery = $this->replicas->prepare($sql); |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | $resultQuery->execute(); |
311 | 311 | $results = $resultQuery->fetchAll(); |
312 | 312 | $namespaceTotals = array_combine( |
313 | - array_map(function ($e) { |
|
313 | + array_map(function($e) { |
|
314 | 314 | return $e['page_namespace']; |
315 | 315 | }, $results), |
316 | - array_map(function ($e) { |
|
316 | + array_map(function($e) { |
|
317 | 317 | return $e['total']; |
318 | 318 | }, $results) |
319 | 319 | ); |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " |
340 | 340 | . " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " |
341 | 341 | . " page_title, page_namespace " |
342 | - . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) |
|
343 | - . " JOIN " . $this->labsHelper->getTable('page', $project['dbName']) |
|
342 | + . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) |
|
343 | + . " JOIN ".$this->labsHelper->getTable('page', $project['dbName']) |
|
344 | 344 | . " ON (rev_page = page_id)" |
345 | 345 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" |
346 | 346 | . " ORDER BY rev_timestamp DESC" |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | continue; |
356 | 356 | } |
357 | 357 | $revsWithProject = array_map( |
358 | - function (&$item) use ($project) { |
|
358 | + function(&$item) use ($project) { |
|
359 | 359 | $item['project_name'] = $project['name']; |
360 | 360 | $item['project_url'] = $project['url']; |
361 | 361 | $item['project_db_name'] = $project['dbName']; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | ); |
367 | 367 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
368 | 368 | } |
369 | - usort($allRevisions, function ($a, $b) { |
|
370 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
369 | + usort($allRevisions, function($a, $b) { |
|
370 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
371 | 371 | }); |
372 | 372 | return array_slice($allRevisions, 0, $contribCount); |
373 | 373 | } |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | . " MONTH(rev_timestamp) AS `month`," |
390 | 390 | . " page_namespace," |
391 | 391 | . " COUNT(rev_id) AS `count` " |
392 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
393 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" |
|
392 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
393 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" |
|
394 | 394 | . " WHERE rev_user_text = :username" |
395 | 395 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " |
396 | 396 | . " ORDER BY rev_timestamp DESC"; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," |
447 | 447 | . " page_namespace," |
448 | 448 | . " COUNT(rev_id) AS `count` " |
449 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
450 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
451 | - " WHERE rev_user_text = :username" . |
|
452 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
449 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
450 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
451 | + " WHERE rev_user_text = :username". |
|
452 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
453 | 453 | " ORDER BY rev_timestamp DESC "; |
454 | 454 | $resultQuery = $this->replicas->prepare($sql); |
455 | 455 | $resultQuery->bindParam(":username", $username); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | . " DAYOFWEEK(rev_timestamp) AS `y`, " |
491 | 491 | . " $xCalc AS `x`, " |
492 | 492 | . " COUNT(rev_id) AS `r` " |
493 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
493 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
494 | 494 | . " WHERE rev_user_text = :username" |
495 | 495 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " |
496 | 496 | . " "; |