@@ -249,7 +249,6 @@ discard block |
||
249 | 249 | * Get a user's total edit count on one or more project. |
250 | 250 | * Requires the CentralAuth extension to be installed on the project. |
251 | 251 | * |
252 | - * @param string $username The username. |
|
253 | 252 | * @param Project $project The project to start from. |
254 | 253 | * @return mixed[]|boolean Array of total edit counts, or false if none could be found. |
255 | 254 | */ |
@@ -296,7 +295,7 @@ discard block |
||
296 | 295 | |
297 | 296 | /** |
298 | 297 | * Get total edit counts for the top 10 projects for this user. |
299 | - * @param string $username The username. |
|
298 | + * @param string $stopwatchName |
|
300 | 299 | * @return string[] Elements are arrays with 'dbName', 'url', 'name', and 'total'. |
301 | 300 | */ |
302 | 301 | protected function getRevisionCountsAllProjectsNoCentralAuth( |
@@ -402,7 +401,6 @@ discard block |
||
402 | 401 | |
403 | 402 | /** |
404 | 403 | * Get data for a bar chart of monthly edit totals per namespace. |
405 | - * @param string $username The username. |
|
406 | 404 | * @return string[] |
407 | 405 | */ |
408 | 406 | public function getMonthCounts(Project $project, User $user) |
@@ -438,7 +436,6 @@ discard block |
||
438 | 436 | |
439 | 437 | /** |
440 | 438 | * Get yearly edit totals for this user, grouped by namespace. |
441 | - * @param string $username |
|
442 | 439 | * @return string[] ['<namespace>' => ['<year>' => 'total', ... ], ... ] |
443 | 440 | */ |
444 | 441 | public function getYearCounts(Project $project, User $user) |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | public function getRevisionCounts(Project $project, User $user) |
18 | 18 | { |
19 | 19 | // Set up cache. |
20 | - $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
20 | + $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
21 | 21 | if ($this->cache->hasItem($cacheKey)) { |
22 | 22 | return $this->cache->getItem($cacheKey)->get(); |
23 | 23 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function getRevisionDates(Project $project, User $user) |
79 | 79 | { |
80 | 80 | // Set up cache. |
81 | - $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
81 | + $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
82 | 82 | if ($this->cache->hasItem($cacheKey)) { |
83 | 83 | return $this->cache->getItem($cacheKey)->get(); |
84 | 84 | } |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | $results = $resultQuery->fetchAll(); |
151 | 151 | |
152 | 152 | $pageCounts = array_combine( |
153 | - array_map(function ($e) { |
|
153 | + array_map(function($e) { |
|
154 | 154 | return $e['source']; |
155 | 155 | }, $results), |
156 | - array_map(function ($e) { |
|
156 | + array_map(function($e) { |
|
157 | 157 | return $e['value']; |
158 | 158 | }, $results) |
159 | 159 | ); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | // Query. |
186 | 186 | $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value |
187 | - FROM " . $this->getTableName($project->getDatabaseName(), 'logging') . " |
|
187 | + FROM " . $this->getTableName($project->getDatabaseName(), 'logging')." |
|
188 | 188 | WHERE log_user = :userId |
189 | 189 | GROUP BY log_type, log_action"; |
190 | 190 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | $resultQuery->execute(); |
194 | 194 | $results = $resultQuery->fetchAll(); |
195 | 195 | $logCounts = array_combine( |
196 | - array_map(function ($e) { |
|
196 | + array_map(function($e) { |
|
197 | 197 | return $e['source']; |
198 | 198 | }, $results), |
199 | - array_map(function ($e) { |
|
199 | + array_map(function($e) { |
|
200 | 200 | return $e['value']; |
201 | 201 | }, $results) |
202 | 202 | ); |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | $resultQuery->bindParam(":id", $userId); |
343 | 343 | $resultQuery->execute(); |
344 | 344 | $results = $resultQuery->fetchAll(); |
345 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
345 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
346 | 346 | return $e['page_namespace']; |
347 | - }, $results), array_map(function ($e) { |
|
347 | + }, $results), array_map(function($e) { |
|
348 | 348 | return $e['total']; |
349 | 349 | }, $results)); |
350 | 350 | return $namespaceTotals; |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | $revisions = $this->cacheGet($cacheKey); |
367 | 367 | } else { |
368 | 368 | $sql = |
369 | - "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " . |
|
370 | - " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " . |
|
371 | - " page_title, page_namespace " . " FROM " . |
|
372 | - $this->labsHelper->getTable('revision', $project['dbName']) . " JOIN " . |
|
373 | - $this->labsHelper->getTable('page', $project['dbName']) . |
|
374 | - " ON (rev_page = page_id)" . |
|
375 | - " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" . |
|
376 | - " ORDER BY rev_timestamp DESC" . " LIMIT 10"; |
|
369 | + "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ". |
|
370 | + " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ". |
|
371 | + " page_title, page_namespace "." FROM ". |
|
372 | + $this->labsHelper->getTable('revision', $project['dbName'])." JOIN ". |
|
373 | + $this->labsHelper->getTable('page', $project['dbName']). |
|
374 | + " ON (rev_page = page_id)". |
|
375 | + " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username". |
|
376 | + " ORDER BY rev_timestamp DESC"." LIMIT 10"; |
|
377 | 377 | $resultQuery = $this->replicas->prepare($sql); |
378 | 378 | $resultQuery->bindParam(":username", $username); |
379 | 379 | $resultQuery->execute(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | if (count($revisions) === 0) { |
384 | 384 | continue; |
385 | 385 | } |
386 | - $revsWithProject = array_map(function (&$item) use ($project) { |
|
386 | + $revsWithProject = array_map(function(&$item) use ($project) { |
|
387 | 387 | $item['project_name'] = $project['wikiName']; |
388 | 388 | $item['project_url'] = $project['url']; |
389 | 389 | $item['project_db_name'] = $project['dbName']; |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | }, $revisions); |
394 | 394 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
395 | 395 | } |
396 | - usort($allRevisions, function ($a, $b) { |
|
397 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
396 | + usort($allRevisions, function($a, $b) { |
|
397 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
398 | 398 | }); |
399 | 399 | |
400 | 400 | return array_slice($allRevisions, 0, $topN); |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $revisionTable = $this->getTableName($project->getDatabaseName(), 'revision'); |
417 | 417 | $pageTable = $this->getTableName($project->getDatabaseName(), 'page'); |
418 | 418 | $sql = |
419 | - "SELECT " . " YEAR(rev_timestamp) AS `year`," . |
|
420 | - " MONTH(rev_timestamp) AS `month`," . " page_namespace," . |
|
419 | + "SELECT "." YEAR(rev_timestamp) AS `year`,". |
|
420 | + " MONTH(rev_timestamp) AS `month`,"." page_namespace,". |
|
421 | 421 | " COUNT(rev_id) AS `count` " |
422 | - . " FROM $revisionTable JOIN $pageTable ON (rev_page = page_id)" . |
|
423 | - " WHERE rev_user_text = :username" . |
|
424 | - " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " . |
|
422 | + . " FROM $revisionTable JOIN $pageTable ON (rev_page = page_id)". |
|
423 | + " WHERE rev_user_text = :username". |
|
424 | + " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ". |
|
425 | 425 | " ORDER BY rev_timestamp DESC"; |
426 | 426 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
427 | 427 | $resultQuery->bindParam(":username", $username); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function getRevisionCounts() |
43 | 43 | { |
44 | - if (! is_array($this->revisionCounts)) { |
|
44 | + if (!is_array($this->revisionCounts)) { |
|
45 | 45 | $this->revisionCounts = $this->getRepository() |
46 | 46 | ->getRevisionCounts($this->project, $this->user); |
47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function getRevisionDates() |
56 | 56 | { |
57 | - if (! is_array($this->revisionDates)) { |
|
57 | + if (!is_array($this->revisionDates)) { |
|
58 | 58 | $this->revisionDates = $this->getRepository() |
59 | 59 | ->getRevisionDates($this->project, $this->user); |
60 | 60 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | protected function getPageCounts() |
69 | 69 | { |
70 | - if (! is_array($this->pageCounts)) { |
|
70 | + if (!is_array($this->pageCounts)) { |
|
71 | 71 | $this->pageCounts = $this->getRepository() |
72 | 72 | ->getPageCounts($this->project, $this->user); |
73 | 73 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function getLogCounts() |
82 | 82 | { |
83 | - if (! is_array($this->logCounts)) { |
|
83 | + if (!is_array($this->logCounts)) { |
|
84 | 84 | $this->logCounts = $this->getRepository() |
85 | 85 | ->getLogCounts($this->project, $this->user); |
86 | 86 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function countAllRevisions() |
111 | 111 | { |
112 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
112 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function countRevisionsWithoutComments() |
130 | 130 | { |
131 | - return $this->countAllRevisions() - $this->countRevisionsWithComments(); |
|
131 | + return $this->countAllRevisions()-$this->countRevisionsWithComments(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function countAllPagesEdited() |
197 | 197 | { |
198 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
198 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function countPagesCreated() |
215 | 215 | { |
216 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
216 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | public function approvals() |
360 | 360 | { |
361 | 361 | $logCounts = $this->getLogCounts(); |
362 | - $total = $logCounts['review-approve'] + |
|
363 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
364 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
362 | + $total = $logCounts['review-approve']+ |
|
363 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
364 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
365 | 365 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
366 | 366 | return $total; |
367 | 367 | } |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | // Get counts. |
388 | 388 | $editCounts = $this->getRepository()->getRevisionCountsAllProjects($user, $project); |
389 | 389 | // Sort. |
390 | - uasort($editCounts, function ($a, $b) { |
|
391 | - return $b['total'] - $a['total']; |
|
390 | + uasort($editCounts, function($a, $b) { |
|
391 | + return $b['total']-$a['total']; |
|
392 | 392 | }); |
393 | 393 | // Truncate, and return. |
394 | 394 | return array_slice($editCounts, 0, $numProjects); |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | if (!isset($out['totals'][$ns])) { |
458 | 458 | $out['totals'][$ns] = []; |
459 | 459 | } |
460 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
460 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
461 | 461 | } |
462 | 462 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
463 | 463 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
464 | 464 | for ($m = 1; $m <= 12; $m++) { |
465 | 465 | foreach ($out['totals'] as $nsId => &$total) { |
466 | - if (!isset($total[$y . $m])) { |
|
467 | - $total[$y . $m] = 0; |
|
466 | + if (!isset($total[$y.$m])) { |
|
467 | + $total[$y.$m] = 0; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | } |