Completed
Push — master ( 61d54e...4a5166 )
by Sam
03:19
created
src/Xtools/EditCounterRepository.php 2 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -250,7 +250,6 @@  discard block
 block discarded – undo
250 250
      * Get a user's total edit count on one or more project.
251 251
      * Requires the CentralAuth extension to be installed on the project.
252 252
      *
253
-     * @param string $username The username.
254 253
      * @param Project $project The project to start from.
255 254
      * @return mixed[]|boolean Array of total edit counts, or false if none could be found.
256 255
      */
@@ -300,7 +299,7 @@  discard block
 block discarded – undo
300 299
 
301 300
     /**
302 301
      * Get total edit counts for the top 10 projects for this user.
303
-     * @param string $username The username.
302
+     * @param string $stopwatchName
304 303
      * @return string[] Elements are arrays with 'dbName', 'url', 'name', and 'total'.
305 304
      */
306 305
     protected function getRevisionCountsAllProjectsNoCentralAuth(
@@ -395,7 +394,6 @@  discard block
 block discarded – undo
395 394
 
396 395
     /**
397 396
      * Get this user's most recent 10 edits across all projects.
398
-     * @param string $username The username.
399 397
      * @param integer $topN The number of items to return.
400 398
      * @param integer $days The number of days to search from each wiki.
401 399
      * @return string[]
@@ -453,7 +451,6 @@  discard block
 block discarded – undo
453 451
 
454 452
     /**
455 453
      * Get data for a bar chart of monthly edit totals per namespace.
456
-     * @param string $username The username.
457 454
      * @return string[]
458 455
      */
459 456
     public function getMonthCounts(Project $project, User $user)
@@ -489,7 +486,6 @@  discard block
 block discarded – undo
489 486
 
490 487
     /**
491 488
      * Get yearly edit totals for this user, grouped by namespace.
492
-     * @param string $username
493 489
      * @return string[] ['<namespace>' => ['<year>' => 'total', ... ], ... ]
494 490
      */
495 491
     public function getYearCounts(Project $project, User $user)
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function getRevisionCounts(Project $project, User $user)
19 19
     {
20 20
         // Set up cache.
21
-        $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername();
21
+        $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername();
22 22
         if ($this->cache->hasItem($cacheKey)) {
23 23
             return $this->cache->getItem($cacheKey)->get();
24 24
         }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     public function getRevisionDates(Project $project, User $user)
80 80
     {
81 81
         // Set up cache.
82
-        $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername();
82
+        $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername();
83 83
         if ($this->cache->hasItem($cacheKey)) {
84 84
             return $this->cache->getItem($cacheKey)->get();
85 85
         }
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
         $results = $resultQuery->fetchAll();
152 152
 
153 153
         $pageCounts = array_combine(
154
-            array_map(function ($e) {
154
+            array_map(function($e) {
155 155
                 return $e['source'];
156 156
             }, $results),
157
-            array_map(function ($e) {
157
+            array_map(function($e) {
158 158
                 return $e['value'];
159 159
             }, $results)
160 160
         );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
         // Query.
187 187
         $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value
188
-            FROM " . $this->getTableName($project->getDatabaseName(), 'logging') . "
188
+            FROM " . $this->getTableName($project->getDatabaseName(), 'logging')."
189 189
             WHERE log_user = :userId
190 190
             GROUP BY log_type, log_action";
191 191
         $resultQuery = $this->getProjectsConnection()->prepare($sql);
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
         $resultQuery->execute();
195 195
         $results = $resultQuery->fetchAll();
196 196
         $logCounts = array_combine(
197
-            array_map(function ($e) {
197
+            array_map(function($e) {
198 198
                 return $e['source'];
199 199
             }, $results),
200
-            array_map(function ($e) {
200
+            array_map(function($e) {
201 201
                 return $e['value'];
202 202
             }, $results)
203 203
         );
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
         $resultQuery->bindParam(":id", $userId);
347 347
         $resultQuery->execute();
348 348
         $results = $resultQuery->fetchAll();
349
-        $namespaceTotals = array_combine(array_map(function ($e) {
349
+        $namespaceTotals = array_combine(array_map(function($e) {
350 350
             return $e['page_namespace'];
351
-        }, $results), array_map(function ($e) {
351
+        }, $results), array_map(function($e) {
352 352
             return $e['total'];
353 353
         }, $results));
354 354
         return $namespaceTotals;
@@ -412,14 +412,14 @@  discard block
 block discarded – undo
412 412
                 $revisions = $this->cache->getItem($cacheKey)->get();
413 413
             } else {
414 414
                 $sql =
415
-                    "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " .
416
-                    " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " .
417
-                    " page_title, page_namespace " . " FROM " .
418
-                    $this->getTableName($project['dbname'], 'revision') . "    JOIN " .
419
-                    $this->getTableName($project['dbname'], 'page') .
420
-                    "    ON (rev_page = page_id)" .
421
-                    " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" .
422
-                    " ORDER BY rev_timestamp DESC" . " LIMIT 10";
415
+                    "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ".
416
+                    " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ".
417
+                    " page_title, page_namespace "." FROM ".
418
+                    $this->getTableName($project['dbname'], 'revision')."    JOIN ".
419
+                    $this->getTableName($project['dbname'], 'page').
420
+                    "    ON (rev_page = page_id)".
421
+                    " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username".
422
+                    " ORDER BY rev_timestamp DESC"." LIMIT 10";
423 423
                 $resultQuery = $this->getProjectsConnection()->prepare($sql);
424 424
                 $resultQuery->bindParam(":username", $username);
425 425
                 $resultQuery->execute();
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
             if (count($revisions) === 0) {
435 435
                 continue;
436 436
             }
437
-            $revsWithProject = array_map(function (&$item) use ($project) {
437
+            $revsWithProject = array_map(function(&$item) use ($project) {
438 438
                 $item['project_name'] = $project['wikiName'];
439 439
                 $item['project_url'] = $project['url'];
440 440
                 $item['project_db_name'] = $project['dbName'];
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
             }, $revisions);
445 445
             $allRevisions = array_merge($allRevisions, $revsWithProject);
446 446
         }
447
-        usort($allRevisions, function ($a, $b) {
448
-            return $b['rev_timestamp'] - $a['rev_timestamp'];
447
+        usort($allRevisions, function($a, $b) {
448
+            return $b['rev_timestamp']-$a['rev_timestamp'];
449 449
         });
450 450
 
451 451
         return array_slice($allRevisions, 0, $topN);
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
         $revisionTable = $this->getTableName($project->getDatabaseName(), 'revision');
468 468
         $pageTable = $this->getTableName($project->getDatabaseName(), 'page');
469 469
         $sql =
470
-            "SELECT " . "     YEAR(rev_timestamp) AS `year`," .
471
-            "     MONTH(rev_timestamp) AS `month`," . "     page_namespace," .
470
+            "SELECT "."     YEAR(rev_timestamp) AS `year`,".
471
+            "     MONTH(rev_timestamp) AS `month`,"."     page_namespace,".
472 472
             "     COUNT(rev_id) AS `count` "
473
-            . " FROM $revisionTable    JOIN $pageTable ON (rev_page = page_id)" .
474
-            " WHERE rev_user_text = :username" .
475
-            " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " .
473
+            . " FROM $revisionTable    JOIN $pageTable ON (rev_page = page_id)".
474
+            " WHERE rev_user_text = :username".
475
+            " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ".
476 476
             " ORDER BY rev_timestamp DESC";
477 477
         $resultQuery = $this->getProjectsConnection()->prepare($sql);
478 478
         $resultQuery->bindParam(":username", $username);
Please login to merge, or discard this patch.