@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $normalized = []; |
| 77 | 77 | if (isset($result['query']['normalized'])) { |
| 78 | 78 | array_map( |
| 79 | - function ($e) use (&$normalized) { |
|
| 79 | + function($e) use (&$normalized) { |
|
| 80 | 80 | $normalized[$e['to']] = $e['from']; |
| 81 | 81 | }, |
| 82 | 82 | $result['query']['normalized'] |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
| 162 | 162 | $innerPromise = $this->api->getRequestAsync($query); |
| 163 | 163 | |
| 164 | - $innerPromise->then(function ($result) use (&$data) { |
|
| 164 | + $innerPromise->then(function($result) use (&$data) { |
|
| 165 | 165 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
| 166 | 166 | if (isset($result['error']) || !isset($result['query'])) { |
| 167 | 167 | return $data['promise']->resolve($data); |
@@ -90,20 +90,20 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // MULTIPLIERS (to review) |
| 92 | 92 | $multipliers = [ |
| 93 | - 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 94 | - 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 95 | - 'user-page-mult' => 0.1, # 0 if = |
|
| 96 | - 'patrols-mult' => 1, # 0 if = |
|
| 97 | - 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 93 | + 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 94 | + 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 95 | + 'user-page-mult' => 0.1, # 0 if = |
|
| 96 | + 'patrols-mult' => 1, # 0 if = |
|
| 97 | + 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 98 | 98 | 'afd-mult' => 1.15, |
| 99 | - 'recent-activity-mult' => 0.9, # 0 if = |
|
| 99 | + 'recent-activity-mult' => 0.9, # 0 if = |
|
| 100 | 100 | 'aiv-mult' => 1.15, |
| 101 | - 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 102 | - 'namespaces-mult' => 1.0, # 0 if = |
|
| 103 | - 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 104 | - 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 105 | - 'rpp-mult' => 1.15, # 0 if = |
|
| 106 | - 'user-rights-mult' => 0.75, # 0 if = |
|
| 101 | + 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 102 | + 'namespaces-mult' => 1.0, # 0 if = |
|
| 103 | + 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 104 | + 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 105 | + 'rpp-mult' => 1.15, # 0 if = |
|
| 106 | + 'user-rights-mult' => 0.75, # 0 if = |
|
| 107 | 107 | ]; |
| 108 | 108 | |
| 109 | 109 | // Grab the connection to the replica database (which is separate from the above) |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | $now = new DateTime(); |
| 186 | 186 | $date = new DateTime($value); |
| 187 | 187 | $diff = $date->diff($now); |
| 188 | - $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d'); |
|
| 189 | - $value = $formula - 365; |
|
| 188 | + $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d'); |
|
| 189 | + $value = $formula-365; |
|
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $multiplierKey = $row['source'] . '-mult'; |
|
| 194 | + $multiplierKey = $row['source'].'-mult'; |
|
| 195 | 195 | $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1; |
| 196 | 196 | $score = max(min($value * $multiplier, 100), -100); |
| 197 | 197 | $master[$key]['mult'] = $multiplier; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | // supply as the OFFSET. |
| 149 | 149 | $limitClause = ''; |
| 150 | 150 | if (intval($limit) > 0 && isset($numRevisions)) { |
| 151 | - $offset = $numRevisions - $limit; |
|
| 151 | + $offset = $numRevisions-$limit; |
|
| 152 | 152 | $limitClause = "LIMIT $offset, $limit"; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $time2 = time(); |
| 265 | 265 | |
| 266 | 266 | // If it took over 5 seconds, cache the result for 20 minutes. |
| 267 | - if ($time2 - $time1 > 5) { |
|
| 267 | + if ($time2-$time1 > 5) { |
|
| 268 | 268 | $cacheItem = $this->cache->getItem($cacheKey) |
| 269 | 269 | ->set($result) |
| 270 | 270 | ->expiresAfter(new DateInterval('PT20M')); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $wikidataId = ltrim($page->getWikidataId(), 'Q'); |
| 401 | 401 | |
| 402 | - $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . " |
|
| 402 | + $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')." |
|
| 403 | 403 | FROM wikidatawiki_p.wb_items_per_site |
| 404 | 404 | WHERE ips_item_id = :wikidataId"; |
| 405 | 405 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | |
| 410 | 410 | $result = $resultQuery->fetchAll(); |
| 411 | 411 | |
| 412 | - return $count ? (int) $result[0]['count'] : $result; |
|
| 412 | + return $count ? (int)$result[0]['count'] : $result; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | // Transform to associative array by 'type' |
| 451 | 451 | foreach ($res as $row) { |
| 452 | - $data[$row['type'] . '_count'] = $row['value']; |
|
| 452 | + $data[$row['type'].'_count'] = $row['value']; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | return $data; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | $project = $page->getProject()->getDomain(); |
| 489 | 489 | |
| 490 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
| 490 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
| 491 | 491 | "$project/all-access/user/$title/daily/$start/$end"; |
| 492 | 492 | |
| 493 | 493 | $res = $client->request('GET', $url); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function countAutomatedEdits() |
| 44 | 44 | { |
| 45 | - return (int) $this->getRepository()->countAutomatedEdits( |
|
| 45 | + return (int)$this->getRepository()->countAutomatedEdits( |
|
| 46 | 46 | $this->project, |
| 47 | 47 | $this->user, |
| 48 | 48 | $this->namespace, |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $namespaces = $this->project->getNamespaces(); |
| 72 | 72 | |
| 73 | - return array_map(function ($rev) use ($namespaces) { |
|
| 73 | + return array_map(function($rev) use ($namespaces) { |
|
| 74 | 74 | $pageTitle = $rev['page_title']; |
| 75 | 75 | $fullPageTitle = ''; |
| 76 | 76 | |
| 77 | 77 | if ($rev['page_namespace'] !== '0') { |
| 78 | - $fullPageTitle = $namespaces[$rev['page_namespace']] . ":$pageTitle"; |
|
| 78 | + $fullPageTitle = $namespaces[$rev['page_namespace']].":$pageTitle"; |
|
| 79 | 79 | } else { |
| 80 | 80 | $fullPageTitle = $pageTitle; |
| 81 | 81 | } |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | return [ |
| 84 | 84 | 'full_page_title' => $fullPageTitle, |
| 85 | 85 | 'page_title' => $pageTitle, |
| 86 | - 'page_namespace' => (int) $rev['page_namespace'], |
|
| 87 | - 'rev_id' => (int) $rev['rev_id'], |
|
| 86 | + 'page_namespace' => (int)$rev['page_namespace'], |
|
| 87 | + 'rev_id' => (int)$rev['rev_id'], |
|
| 88 | 88 | 'timestamp' => DateTime::createFromFormat('YmdHis', $rev['timestamp']), |
| 89 | - 'minor' => (bool) $rev['minor'], |
|
| 90 | - 'length' => (int) $rev['length'], |
|
| 91 | - 'length_change' => (int) $rev['length_change'], |
|
| 89 | + 'minor' => (bool)$rev['minor'], |
|
| 90 | + 'length' => (int)$rev['length'], |
|
| 91 | + 'length_change' => (int)$rev['length_change'], |
|
| 92 | 92 | 'comment' => $rev['comment'], |
| 93 | 93 | ]; |
| 94 | 94 | }, $revs); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $tagJoin = $tags != '' ? "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id" : ''; |
| 52 | 52 | $condTools[] = "ct_tag IN ($tags)"; |
| 53 | 53 | } |
| 54 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
| 54 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
| 55 | 55 | |
| 56 | 56 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
| 57 | 57 | FROM $revisionTable |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $condEnd"; |
| 65 | 65 | |
| 66 | 66 | $resultQuery = $this->executeQuery($sql, $user, $namespace, $start, $end); |
| 67 | - $result = (int) $resultQuery->fetchColumn(); |
|
| 67 | + $result = (int)$resultQuery->fetchColumn(); |
|
| 68 | 68 | |
| 69 | 69 | // Cache for 10 minutes, and return. |
| 70 | 70 | $this->setCache($cacheKey, $result); |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Sort the array by count |
| 196 | - uasort($results, function ($a, $b) { |
|
| 197 | - return $b['count'] - $a['count']; |
|
| 196 | + uasort($results, function($a, $b) { |
|
| 197 | + return $b['count']-$a['count']; |
|
| 198 | 198 | }); |
| 199 | 199 | |
| 200 | 200 | // Cache for 10 minutes, and return. |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | // Developer error, no regex or tag provided for this tool. |
| 240 | 240 | if ($condTool === '') { |
| 241 | - throw new Exception("No regex or tag found for the tool $toolname. " . |
|
| 241 | + throw new Exception("No regex or tag found for the tool $toolname. ". |
|
| 242 | 242 | "Please verify this entry in semi_automated.yml"); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if ($condTool === '') { |
| 285 | 285 | $condTool = "ct_tag = $tag"; |
| 286 | 286 | } else { |
| 287 | - $condTool = '(' . $condTool . " OR ct_tag = $tag)"; |
|
| 287 | + $condTool = '('.$condTool." OR ct_tag = $tag)"; |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | return $this->editCounts[$domain]; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $this->editCounts[$domain] = (int) $this->getRepository()->getEditCount( |
|
| 96 | + $this->editCounts[$domain] = (int)$this->getRepository()->getEditCount( |
|
| 97 | 97 | $project->getDatabaseName(), |
| 98 | 98 | $this->getUsername() |
| 99 | 99 | ); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function isAnon() |
| 161 | 161 | { |
| 162 | - return (bool) filter_var($this->username, FILTER_VALIDATE_IP); |
|
| 162 | + return (bool)filter_var($this->username, FILTER_VALIDATE_IP); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public function countEdits(Project $project, $namespace = 'all', $start = '', $end = '') |
| 223 | 223 | { |
| 224 | - return (int) $this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
| 224 | + return (int)$this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | // Get individual counts of how many times each tool was used. |
| 127 | 127 | // This also includes a wikilink to the tool. |
| 128 | 128 | $toolCounts = $autoEdits->getAutomatedCounts(); |
| 129 | - $toolsTotal = array_reduce($toolCounts, function ($a, $b) { |
|
| 130 | - return $a + $b['count']; |
|
| 129 | + $toolsTotal = array_reduce($toolCounts, function($a, $b) { |
|
| 130 | + return $a+$b['count']; |
|
| 131 | 131 | }); |
| 132 | 132 | |
| 133 | 133 | // Query to get combined (semi)automated using for all edits |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $res['automated_editcount'] = $autoEdits->countAutomatedEdits(); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $res['nonautomated_editcount'] = $res['total_editcount'] - $res['automated_editcount']; |
|
| 206 | + $res['nonautomated_editcount'] = $res['total_editcount']-$res['automated_editcount']; |
|
| 207 | 207 | |
| 208 | 208 | $response->setData($res); |
| 209 | 209 | return $response; |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | if ($request->query->get('format') !== 'html') { |
| 244 | 244 | return new JsonResponse( |
| 245 | 245 | [ |
| 246 | - 'error' => 'Unable to show any data. User has made over ' . |
|
| 247 | - $user->maxEdits() . ' edits.', |
|
| 246 | + 'error' => 'Unable to show any data. User has made over '. |
|
| 247 | + $user->maxEdits().' edits.', |
|
| 248 | 248 | ], |
| 249 | 249 | Response::HTTP_FORBIDDEN |
| 250 | 250 | ); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | if ($request->query->get('format') === 'html') { |
| 264 | 264 | if ($edits) { |
| 265 | - $edits = array_map(function ($attrs) use ($project, $user) { |
|
| 265 | + $edits = array_map(function($attrs) use ($project, $user) { |
|
| 266 | 266 | $page = $project->getRepository() |
| 267 | 267 | ->getPage($project, $attrs['full_page_title']); |
| 268 | 268 | $pageTitles[] = $attrs['full_page_title']; |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | ]; |
| 233 | 233 | |
| 234 | 234 | if ($pages->getNumResults() === $pages->resultsPerPage()) { |
| 235 | - $ret['continue'] = $offset + 1; |
|
| 235 | + $ret['continue'] = $offset+1; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | $ret['pages'] = $pagesList; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $params = $this->convertLegacyParams($params); |
| 39 | 39 | |
| 40 | 40 | // Remove blank values. |
| 41 | - return array_filter($params, function ($param) { |
|
| 41 | + return array_filter($params, function($param) { |
|
| 42 | 42 | // 'namespace' or 'username' could be '0'. |
| 43 | 43 | return $param !== null && $param !== ''; |
| 44 | 44 | }); |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $conn = $this->container->get('doctrine') |
| 331 | 331 | ->getManager('default') |
| 332 | 332 | ->getConnection(); |
| 333 | - $date = date('Y-m-d'); |
|
| 333 | + $date = date('Y-m-d'); |
|
| 334 | 334 | |
| 335 | 335 | // Increment count in timeline |
| 336 | 336 | $existsSql = "SELECT 1 FROM usage_api_timeline |