@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | public function register() |
21 | 21 | { |
22 | - $this->getContainer()->share('League\Fractal\Manager', function () { |
|
22 | + $this->getContainer()->share('League\Fractal\Manager', function() { |
|
23 | 23 | return new Manager; |
24 | 24 | }); |
25 | 25 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function register() |
23 | 23 | { |
24 | - $this->getContainer()->share('Monolog\Logger', function () { |
|
24 | + $this->getContainer()->share('Monolog\Logger', function() { |
|
25 | 25 | $log = new Logger('app'); |
26 | 26 | |
27 | 27 | $config = $this->getContainer()->get('config'); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | $log->pushHandler( |
42 | - new StreamHandler(__DIR__ . '/../../logs/app.log', Logger::DEBUG) |
|
42 | + new StreamHandler(__DIR__.'/../../logs/app.log', Logger::DEBUG) |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | return $log; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | public function register() |
21 | 21 | { |
22 | - $this->getContainer()->add('GuzzleHttp\Client', function () { |
|
22 | + $this->getContainer()->add('GuzzleHttp\Client', function() { |
|
23 | 23 | return new Client([ |
24 | 24 | 'timeout' => 10.0 |
25 | 25 | ]); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $missing = 0; |
41 | 41 | $max = $result->ResultID; |
42 | 42 | |
43 | - while($count < $max) { |
|
43 | + while ($count < $max) { |
|
44 | 44 | $count++; |
45 | 45 | |
46 | 46 | $per = round(($count / $max) * 100, 2); |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $servers = $this->config['servers']; |
35 | 35 | $servers[] = 0; |
36 | 36 | |
37 | - foreach($servers as $server) { |
|
37 | + foreach ($servers as $server) { |
|
38 | 38 | $output->writeln("Checking Server {$server}"); |
39 | 39 | |
40 | 40 | $key = "ps2alerts:api:leaderboards:status:{$server}"; |
41 | 41 | $resultKey = "ps2alerts:api:leaderboards:lastResult:{$server}"; |
42 | 42 | |
43 | - if (! $this->redis->exists($key)) { |
|
43 | + if (!$this->redis->exists($key)) { |
|
44 | 44 | $output->writeln("Key doesn't exist for server {$server}! Forcing!"); |
45 | 45 | $this->update($server, $output); |
46 | 46 | continue; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $row = $statement->fetch(\PDO::FETCH_OBJ); |
70 | 70 | $force = false; |
71 | 71 | |
72 | - if (! $this->redis->exists($resultKey)) { |
|
72 | + if (!$this->redis->exists($resultKey)) { |
|
73 | 73 | $force = true; |
74 | 74 | } else { |
75 | 75 | $lastResult = $this->redis->get($resultKey); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function convert($size) { |
4 | - $unit=array('B','KB','MB','GB','TB','PB'); |
|
5 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; |
|
4 | + $unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); |
|
5 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[$i]; |
|
6 | 6 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $this->playerLeaderboards($input, $output); |
32 | 32 | |
33 | 33 | $end = microtime(true); |
34 | - $output->writeln("Processing took " . gmdate("H:i:s", ($end - $start))); |
|
34 | + $output->writeln("Processing took ".gmdate("H:i:s", ($end - $start))); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function playerLeaderboards(InputInterface $input, OutputInterface $output) |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | |
48 | 48 | // Allows server 0, meaning all servers but not to process every server |
49 | 49 | if ($serverArg === 'all') { |
50 | - $servers = [0,1,10,13,17,25,1000,2000]; |
|
50 | + $servers = [0, 1, 10, 13, 17, 25, 1000, 2000]; |
|
51 | 51 | } else { |
52 | 52 | $servers = [$serverArg]; |
53 | 53 | } |
54 | 54 | |
55 | - foreach($servers as $server) { |
|
56 | - foreach($metrics as $metric) { |
|
55 | + foreach ($servers as $server) { |
|
56 | + foreach ($metrics as $metric) { |
|
57 | 57 | $this->markAsBeingUpdated($metric, $server); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - foreach($servers as $server) { |
|
62 | - foreach($metrics as $metric) { |
|
61 | + foreach ($servers as $server) { |
|
62 | + foreach ($metrics as $metric) { |
|
63 | 63 | $count = 0; |
64 | 64 | $limit = 10000; |
65 | 65 | $ladderLimit = 10000; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if ($server != 0) { |
90 | 90 | $query->where("playerServer = ?", $server); |
91 | 91 | } |
92 | - $query->orderBy([$metric . ' DESC']); |
|
92 | + $query->orderBy([$metric.' DESC']); |
|
93 | 93 | $query->limit($limit); |
94 | 94 | $query->offset($count); |
95 | 95 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $playerPosKey = "ps2alerts:api:leaderboards:players:pos:{$player->playerID}"; |
105 | 105 | |
106 | 106 | // If player record doesn't exist |
107 | - if (! $this->redis->exists($playerPosKey)) { |
|
107 | + if (!$this->redis->exists($playerPosKey)) { |
|
108 | 108 | $data = [ |
109 | 109 | 'updated' => [ |
110 | 110 | 'daily' => date('U'), |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'monthly' |
123 | 123 | ]; |
124 | 124 | |
125 | - foreach($deadlines as $deadline) { |
|
125 | + foreach ($deadlines as $deadline) { |
|
126 | 126 | // Create the array if empty |
127 | 127 | if (empty($data[$server][$metric][$deadline])) { |
128 | 128 | $data[$server][$metric][$deadline] = []; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | // Flip new to old |
141 | - if (! empty($row)) { |
|
141 | + if (!empty($row)) { |
|
142 | 142 | $row['old']['pos'] = $row['new']['pos']; |
143 | 143 | $row['old']['val'] = $row['new']['val']; |
144 | 144 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $key = "ps2alerts:api:leaderboards:status:{$server}"; |
190 | 190 | |
191 | 191 | // Create the key if it doesn't exist for some reason (1st runs) |
192 | - if (! $this->redis->exists($key)) { |
|
192 | + if (!$this->redis->exists($key)) { |
|
193 | 193 | $data = [ |
194 | 194 | 'beingUpdated' => 1, |
195 | 195 | 'lastUpdated' => date('U'), |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ) { |
195 | 195 | // Check each cols to make sure we handle SUM(BLAH) AS BLAH issues |
196 | 196 | |
197 | - foreach($cols as $key => $col) { |
|
197 | + foreach ($cols as $key => $col) { |
|
198 | 198 | if (strpos($col, 'AS ') !== false) { |
199 | 199 | $pos = strrpos($col, 'AS ') + 3; // Plus 3 for "AS " |
200 | 200 | $len = strlen($col); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $query->from($table); |
211 | 211 | $query->where('resultID = ?', $id); |
212 | 212 | |
213 | - if (! empty($groupBy)) { |
|
213 | + if (!empty($groupBy)) { |
|
214 | 214 | $query->groupBy($groupBy); |
215 | 215 | } |
216 | 216 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $update->table($totalsTable); |
227 | 227 | $update->where("{$filter} = ?", $row->$filter); |
228 | 228 | |
229 | - foreach($fields as $field) { |
|
229 | + foreach ($fields as $field) { |
|
230 | 230 | $update->set($field, "{$field} - {$row->$field}"); |
231 | 231 | } |
232 | 232 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | protected function deleteAllFromTables(array $tables, $id, OutputInterface $output) |
241 | 241 | { |
242 | - foreach($tables as $table) { |
|
242 | + foreach ($tables as $table) { |
|
243 | 243 | $delete = $this->auraFactory->newDelete(); |
244 | 244 | $delete->from($table); |
245 | 245 | $delete->where('resultID = ?', $id); |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | $query->where('ResultStartTime < ?', $obj->format('U')); |
62 | 62 | $query->where('Archived = 0'); |
63 | 63 | |
64 | - if (! empty($input->getArgument('start'))) { |
|
64 | + if (!empty($input->getArgument('start'))) { |
|
65 | 65 | $query->where('ResultID >= ?', $input->getArgument('start')); |
66 | 66 | } |
67 | 67 | |
68 | - if (! empty($input->getArgument('process'))) { |
|
68 | + if (!empty($input->getArgument('process'))) { |
|
69 | 69 | $query->where('ResultID <= ?', $input->getArgument('process')); |
70 | 70 | } |
71 | 71 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'ws_xp' |
91 | 91 | ]; |
92 | 92 | |
93 | - for ($i=0; $i < $count; $i++) { |
|
93 | + for ($i = 0; $i < $count; $i++) { |
|
94 | 94 | $this->archive($alerts[$i], $tables, $output); |
95 | 95 | |
96 | 96 | $per = ($i / $count) * 100; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $this->guzzle->request( |
112 | 112 | 'POST', |
113 | 113 | 'https://hooks.slack.com/services/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', |
114 | - ['json' => $payload ] |
|
114 | + ['json' => $payload] |
|
115 | 115 | ); |
116 | 116 | |
117 | 117 | $output->writeln("Archived {$records} records!"); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $this->dbArchive->beginTransaction(); |
134 | 134 | |
135 | 135 | // Get all data and insert it into the archive DB |
136 | - foreach($tables as $table) { |
|
136 | + foreach ($tables as $table) { |
|
137 | 137 | $output->writeln("Alert #{$alert['ResultID']} - Table: {$table}"); |
138 | 138 | |
139 | 139 | $sql = "SELECT * FROM {$table} WHERE resultID = :result"; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | $values = rtrim($values, ','); |
158 | - $sql = "INSERT INTO {$table} ({$cols}) VALUES {$values}"; |
|
158 | + $sql = "INSERT INTO {$table} ({$cols}) VALUES {$values}"; |
|
159 | 159 | |
160 | 160 | $this->dbArchive->exec($sql); |
161 | 161 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $this->db->beginTransaction(); |
176 | 176 | |
177 | 177 | // Loop through all tables and delete the alert's data from the DB |
178 | - foreach($tables as $table) { |
|
178 | + foreach ($tables as $table) { |
|
179 | 179 | $sql = "DELETE FROM {$table} WHERE resultID = :result"; |
180 | 180 | $stm = $this->db->prepare($sql); |
181 | 181 | $stm->execute(['result' => $alert['ResultID']]); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | public function buildCols($row) |
208 | 208 | { |
209 | 209 | $keys = []; |
210 | - foreach($row as $key => $val) { |
|
210 | + foreach ($row as $key => $val) { |
|
211 | 211 | $keys[] = (string) $key; |
212 | 212 | } |
213 | 213 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function buildValues($row) |
225 | 225 | { |
226 | 226 | $values = []; |
227 | - foreach($row as $key => $val) { |
|
227 | + foreach ($row as $key => $val) { |
|
228 | 228 | $val = str_replace("'", '', $val); // Remove any apostophies from char names |
229 | 229 | $values[] = $val; |
230 | 230 | } |