Failed Conditions
Pull Request — master (#353)
by Florian
03:08
created
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 168
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
169 169
                 FROM sightings
170
-	            WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0'
170
+	            WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
171 171
 	            ORDER BY $top_order_by $top_direction, expire_timestamp DESC
172 172
 	            LIMIT 50 OFFSET 0";
173 173
 		$result = pg_query($this->db, $req);
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
182 182
 		$trainer_blacklist = "";
183 183
 		if (!empty(self::$config->system->trainer_blacklist)) {
184
-			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
184
+			$trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
185 185
 		}
186 186
 
187 187
 		$req = "SELECT DISTINCT external_id, owner_name as trainer_name, ROUND((100.0*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS \"IV\", move_1, move_2, cp as cp,
188 188
                 TO_TIMESTAMP(last_modified) AS lasttime, last_modified as last_seen
189 189
                 FROM gym_defenders
190
-				WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . "
190
+				WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist."
191 191
 				GROUP BY external_id, owner_name, atk_iv, def_iv, sta_iv, move_1, move_2, cp, last_modified
192 192
 				ORDER BY $best_order_by $best_direction, owner_name ASC
193 193
 				LIMIT 50 OFFSET 0";
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 
231 231
 	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
232 232
 		$inmap_pkms_filter = "";
233
-		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
233
+		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = ".$pokemon_id;
234 234
 
235
-		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where;
235
+		$reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where;
236 236
 		$resultTestIv = pg_query($this->db, $reqTestIv);
237 237
 		$testIv = pg_fetch_object($resultTestIv);
238 238
 		if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) {
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 				$inmap_pkms_filter .= "'".$inmap."',";
241 241
 			}
242 242
 			$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
243
-			$where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") ";
243
+			$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
244 244
 		}
245 245
 		if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) {
246
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") ";
246
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") ";
247 247
 		}
248 248
 		if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) {
249
-			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") ";
249
+			$where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") ";
250 250
 		}
251 251
 		$req = "SELECT pokemon_id, lat AS latitude, lon AS longitude,
252 252
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time,
253 253
     					TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
254 254
     					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
255 255
    						move_1, move_2
256
-					FROM sightings " . $where . "
256
+					FROM sightings " . $where."
257 257
 					ORDER BY disappear_time DESC
258 258
 					LIMIT 5000";
259 259
 		$result = pg_query($this->db, $req);
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		$req = "SELECT COUNT(DISTINCT(fs.fort_id)) AS total, ROUND((SUM(gd.cp)) / COUNT(DISTINCT(fs.fort_id)),0) AS average_points
323 323
         			FROM fort_sightings fs
324 324
         			JOIN gym_defenders gd ON fs.fort_id = gd.fort_id
325
-        			WHERE fs.team = '" . $team_id . "'";
325
+        			WHERE fs.team = '" . $team_id."'";
326 326
 		$result = pg_query($this->db, $req);
327 327
 		$data = pg_fetch_object($result);
328 328
 		return $data;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	///////////
370 370
 
371 371
 	public function getAllRaids($page) {
372
-		$limit = " LIMIT 10 OFFSET ". ($page * 10);
372
+		$limit = " LIMIT 10 OFFSET ".($page * 10);
373 373
 		$req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude 
374 374
 					FROM raids r 
375 375
 					JOIN forts f ON f.id = r.fort_id 
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 					FROM sightings
439 439
 					JOIN (SELECT COUNT(*) AS count
440 440
 						FROM sightings
441
-                    	" . $where. "
441
+                    	" . $where."
442 442
                     ) count ON 1 = 1
443
-					" . $where . "
443
+					" . $where."
444 444
 					ORDER BY expire_timestamp DESC
445 445
 					LIMIT 1 OFFSET 0";
446 446
 		$result = pg_query($this->db, $req);
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
 	public function getNestData() {
476 476
 		$pokemon_exclude_sql = "";
477 477
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
478
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
478
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
479 479
 		}
480 480
 		$req = "SELECT p.spawn_id, p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, TO_TIMESTAMP(MAX(s.updated)) as latest_seen, coalesce(MAX(duration),30)*60 as duration
481 481
 			          FROM sightings p
482 482
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
483 483
 			          WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - 86400
484
-			          " . $pokemon_exclude_sql . "
484
+			          " . $pokemon_exclude_sql."
485 485
 			          GROUP BY p.spawn_id, p.pokemon_id
486 486
 			          HAVING COUNT(p.pokemon_id) >= 6
487 487
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +76 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,13 +6,16 @@  discard block
 block discarded – undo
6 6
  * Time: 02:26
7 7
  */
8 8
 
9
-class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql {
9
+class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql
10
+{
10 11
 
11
-	public function __construct() {
12
+	public function __construct()
13
+	{
12 14
 		parent::__construct();
13 15
 	}
14 16
 
15
-	public function __destruct() {
17
+	public function __destruct()
18
+	{
16 19
 		parent::__destruct();
17 20
 	}
18 21
 
@@ -20,7 +23,8 @@  discard block
 block discarded – undo
20 23
 	// Tester
21 24
 	///////////
22 25
 
23
-	function testTotalPokemon() {
26
+	function testTotalPokemon()
27
+	{
24 28
 		$req = "SELECT COUNT(*) as total FROM sightings";
25 29
 		$result = pg_query($this->db, $req);
26 30
 		if ($result === false) {
@@ -36,7 +40,8 @@  discard block
 block discarded – undo
36 40
 		return 0;
37 41
 	}
38 42
 
39
-	function testTotalGyms() {
43
+	function testTotalGyms()
44
+	{
40 45
 		$req = "SELECT COUNT(*) as total FROM forts";
41 46
 		$result = pg_query($this->db, $req);
42 47
 		if ($result === false) {
@@ -52,7 +57,8 @@  discard block
 block discarded – undo
52 57
 		return 0;
53 58
 	}
54 59
 
55
-	function testTotalPokestops() {
60
+	function testTotalPokestops()
61
+	{
56 62
 		$req = "SELECT COUNT(*) as total FROM pokestops";
57 63
 		$result = pg_query($this->db, $req);
58 64
 		if ($result === false) {
@@ -73,26 +79,30 @@  discard block
 block discarded – undo
73 79
 	// Homepage
74 80
 	/////////////
75 81
 
76
-	function getTotalPokemon() {
82
+	function getTotalPokemon()
83
+	{
77 84
 		$req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW())";
78 85
 		$result = pg_query($this->db, $req);
79 86
 		$data = pg_fetch_object($result);
80 87
 		return $data;
81 88
 	}
82 89
 
83
-	function getTotalLures() {
90
+	function getTotalLures()
91
+	{
84 92
 		$data = (object) array("total" => 0);
85 93
 		return $data;
86 94
 	}
87 95
 
88
-	function getTotalGyms() {
96
+	function getTotalGyms()
97
+	{
89 98
 		$req = "SELECT COUNT(*) AS total FROM forts";
90 99
 		$result = pg_query($this->db, $req);
91 100
 		$data = pg_fetch_object($result);
92 101
 		return $data;
93 102
 	}
94 103
 
95
-	function getTotalRaids() {
104
+	function getTotalRaids()
105
+	{
96 106
 		$req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())";
97 107
 		$result = pg_query($this->db, $req);
98 108
 		$data = pg_fetch_object($result);
@@ -100,14 +110,16 @@  discard block
 block discarded – undo
100 110
 	}
101 111
 
102 112
 
103
-	function getTotalGymsForTeam($team_id) {
113
+	function getTotalGymsForTeam($team_id)
114
+	{
104 115
 		$req = "SELECT COUNT(*) AS total FROM fort_sightings WHERE team = '$team_id'";
105 116
 		$result = pg_query($this->db, $req);
106 117
 		$data = pg_fetch_object($result);
107 118
 		return $data;
108 119
 	}
109 120
 
110
-	function getRecentAll() {
121
+	function getRecentAll()
122
+	{
111 123
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
112 124
               lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
113 125
               FROM sightings
@@ -123,7 +135,8 @@  discard block
 block discarded – undo
123 135
 		return $data;
124 136
 	}
125 137
 
126
-	function getRecentMythic($mythic_pokemon) {
138
+	function getRecentMythic($mythic_pokemon)
139
+	{
127 140
 		$req = "SELECT DISTINCT pokemon_id as pokemon_id, CONCAT('A', encounter_id) as encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real,
128 141
                 lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
129 142
                 FROM sightings
@@ -144,14 +157,16 @@  discard block
 block discarded – undo
144 157
 	// Single Pokemon
145 158
 	///////////////////
146 159
 
147
-	function getGymsProtectedByPokemon($pokemon_id) {
160
+	function getGymsProtectedByPokemon($pokemon_id)
161
+	{
148 162
 		$req = "SELECT COUNT(DISTINCT(fort_id)) AS total FROM fort_sightings WHERE guard_pokemon_id = '".$pokemon_id."'";
149 163
 		$result = pg_query($this->db, $req);
150 164
 		$data = pg_fetch_object($result);
151 165
 		return $data;
152 166
 	}
153 167
 
154
-	function getPokemonLastSeen($pokemon_id) {
168
+	function getPokemonLastSeen($pokemon_id)
169
+	{
155 170
 		$req = "SELECT TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
156 171
                 FROM sightings
157 172
                 WHERE pokemon_id = '".$pokemon_id."'
@@ -162,7 +177,8 @@  discard block
 block discarded – undo
162 177
 		return $data;
163 178
 	}
164 179
 
165
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
180
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
181
+	{
166 182
 		$req = "SELECT DISTINCT encounter_id, expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
167 183
                 cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
168 184
                 ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form
@@ -178,7 +194,8 @@  discard block
 block discarded – undo
178 194
 		return $top;
179 195
 	}
180 196
 
181
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
197
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
198
+	{
182 199
 		$trainer_blacklist = "";
183 200
 		if (!empty(self::$config->system->trainer_blacklist)) {
184 201
 			$trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')";
@@ -200,7 +217,8 @@  discard block
 block discarded – undo
200 217
 		return $toptrainer;
201 218
 	}
202 219
 
203
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
220
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
221
+	{
204 222
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
205 223
 			. "AND TO_TIMESTAMP(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
206 224
 		$req 		= "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." ORDER BY expire_timestamp DESC LIMIT 100000";
@@ -212,7 +230,8 @@  discard block
 block discarded – undo
212 230
 		return $points;
213 231
 	}
214 232
 
215
-	public function getPokemonGraph($pokemon_id) {
233
+	public function getPokemonGraph($pokemon_id)
234
+	{
216 235
 		$req = "SELECT COUNT(*) AS total, EXTRACT(HOUR FROM disappear_time) AS disappear_hour
217 236
 					FROM (SELECT TO_TIMESTAMP(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 100000) AS pokemonFiltered
218 237
 				GROUP BY disappear_hour
@@ -228,7 +247,8 @@  discard block
 block discarded – undo
228 247
 		return $array;
229 248
 	}
230 249
 
231
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
250
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
251
+	{
232 252
 		$inmap_pkms_filter = "";
233 253
 		$where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id;
234 254
 
@@ -264,14 +284,16 @@  discard block
 block discarded – undo
264 284
 		return $spawns;
265 285
 	}
266 286
 
267
-	public function getPokemonSliederMinMax() {
287
+	public function getPokemonSliederMinMax()
288
+	{
268 289
 		$req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings";
269 290
 		$result = pg_query($this->db, $req);
270 291
 		$data = pg_fetch_object($result);
271 292
 		return $data;
272 293
 	}
273 294
 
274
-	public function getMapsCoords() {
295
+	public function getMapsCoords()
296
+	{
275 297
 		$req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints";
276 298
 		$result = pg_query($this->db, $req);
277 299
 		$data = pg_fetch_object($result);
@@ -284,14 +306,16 @@  discard block
 block discarded – undo
284 306
 	//////////////
285 307
 
286 308
 
287
-	function getTotalPokestops() {
309
+	function getTotalPokestops()
310
+	{
288 311
 		$req = "SELECT COUNT(*) as total FROM pokestops";
289 312
 		$result = pg_query($this->db, $req);
290 313
 		$data = pg_fetch_object($result);
291 314
 		return $data;
292 315
 	}
293 316
 
294
-	public function getAllPokestops() {
317
+	public function getAllPokestops()
318
+	{
295 319
 		$req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, EXTRACT(EPOCH FROM NOW()) AS now, null AS lure_expiration_real FROM pokestops";
296 320
 		$result = pg_query($this->db, $req);
297 321
 		$pokestops = array();
@@ -306,7 +330,8 @@  discard block
 block discarded – undo
306 330
 	// Gyms
307 331
 	/////////
308 332
 
309
-	function getTeamGuardians($team_id) {
333
+	function getTeamGuardians($team_id)
334
+	{
310 335
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM fort_sightings WHERE team = '".$team_id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 3 OFFSET 0";
311 336
 		$result = pg_query($this->db, $req);
312 337
 
@@ -318,7 +343,8 @@  discard block
 block discarded – undo
318 343
 		return $datas;
319 344
 	}
320 345
 
321
-	function getOwnedAndPoints($team_id) {
346
+	function getOwnedAndPoints($team_id)
347
+	{
322 348
 		$req = "SELECT COUNT(DISTINCT(fs.fort_id)) AS total, ROUND((SUM(gd.cp)) / COUNT(DISTINCT(fs.fort_id)),0) AS average_points
323 349
         			FROM fort_sightings fs
324 350
         			JOIN gym_defenders gd ON fs.fort_id = gd.fort_id
@@ -328,7 +354,8 @@  discard block
 block discarded – undo
328 354
 		return $data;
329 355
 	}
330 356
 
331
-	function getAllGyms() {
357
+	function getAllGyms()
358
+	{
332 359
 		$req = "SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level FROM forts f LEFT JOIN fort_sightings fs ON f.id = fs.fort_id;";
333 360
 		$result = pg_query($this->db, $req);
334 361
 		$gyms = array();
@@ -338,7 +365,8 @@  discard block
 block discarded – undo
338 365
 		return $gyms;
339 366
 	}
340 367
 
341
-	public function getGymData($gym_id) {
368
+	public function getGymData($gym_id)
369
+	{
342 370
 		$req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, TO_TIMESTAMP(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, SUM(gd.cp) as total_cp	
343 371
 			FROM fort_sightings fs
344 372
 			LEFT JOIN forts f ON f.id = fs.fort_id
@@ -350,7 +378,8 @@  discard block
 block discarded – undo
350 378
 		return $data;
351 379
 	}
352 380
 
353
-	public function getGymDefenders($gym_id) {
381
+	public function getGymDefenders($gym_id)
382
+	{
354 383
 		$req = "SELECT DISTINCT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id
355 384
 			FROM gym_defenders 
356 385
 			WHERE fort_id='".$gym_id."'
@@ -368,7 +397,8 @@  discard block
 block discarded – undo
368 397
 	// Raids
369 398
 	///////////
370 399
 
371
-	public function getAllRaids($page) {
400
+	public function getAllRaids($page)
401
+	{
372 402
 		$limit = " LIMIT 10 OFFSET ". ($page * 10);
373 403
 		$req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude 
374 404
 					FROM raids r 
@@ -389,11 +419,13 @@  discard block
 block discarded – undo
389 419
 	// Trainers
390 420
 	//////////////
391 421
 
392
-	public function getTrainers($trainer_name, $team, $page, $ranking) {
422
+	public function getTrainers($trainer_name, $team, $page, $ranking)
423
+	{
393 424
 		return array(); // Waiting for Monocle to store level
394 425
 	}
395 426
 
396
-	public function getTrainerLevelCount($team_id) {
427
+	public function getTrainerLevelCount($team_id)
428
+	{
397 429
 		$levelData = array();
398 430
 		for ($i = 5; $i <= 40; $i++) {
399 431
 			if (!isset($levelData[$i])) {
@@ -408,7 +440,8 @@  discard block
 block discarded – undo
408 440
 	// Cron
409 441
 	/////////
410 442
 
411
-	public function getPokemonCountsActive() {
443
+	public function getPokemonCountsActive()
444
+	{
412 445
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id";
413 446
 		$result = pg_query($this->db, $req);
414 447
 		$counts = array();
@@ -418,7 +451,8 @@  discard block
 block discarded – undo
418 451
 		return $counts;
419 452
 	}
420 453
 
421
-	public function getPoekmonCountsLastDay() {
454
+	public function getPoekmonCountsLastDay()
455
+	{
422 456
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
423 457
 					FROM sightings
424 458
 					WHERE TO_TIMESTAMP(expire_timestamp) >= (SELECT TO_TIMESTAMP(MAX(expire_timestamp)) FROM sightings) - INTERVAL 1 DAY
@@ -432,7 +466,8 @@  discard block
 block discarded – undo
432 466
 		return $counts;
433 467
 	}
434 468
 
435
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
469
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
470
+	{
436 471
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND id > '".$last_update."'";
437 472
 		$req = "SELECT count, id AS last_timestamp, (TO_TIMESTAMP(expire_timestamp)) AS disappear_time_real, lat as latitude, lon as longitude
438 473
 					FROM sightings
@@ -448,7 +483,8 @@  discard block
 block discarded – undo
448 483
 		return $data;
449 484
 	}
450 485
 
451
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
486
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
487
+	{
452 488
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND time_battle > '".$last_update."'";
453 489
 		$req = "SELECT time_battle AS start_timestamp, time_end as end, (TO_TIMESTAMP(time_end)) AS end_time_real, lat as latitude, lon as longitude, count
454 490
 					FROM raids r
@@ -465,14 +501,16 @@  discard block
 block discarded – undo
465 501
 		return $data;
466 502
 	}
467 503
 
468
-	public function getCaptchaCount() {
504
+	public function getCaptchaCount()
505
+	{
469 506
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
470 507
 		$result = pg_query($this->db, $req);
471 508
 		$data = pg_fetch_object($result);
472 509
 		return $data;
473 510
 	}
474 511
 
475
-	public function getNestData() {
512
+	public function getNestData()
513
+	{
476 514
 		$pokemon_exclude_sql = "";
477 515
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
478 516
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
Please login to merge, or discard this patch.
core/process/queries/QueryManagerMysqlRocketmap.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	/////////
303 303
 
304 304
 	function getTeamGuardians($team_id) {
305
-		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
305
+		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
306 306
 		$result = $this->mysqli->query($req);
307 307
 		$datas = array();
308 308
 		while ($data = $result->fetch_object()) {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 				FROM gympokemon
455 455
 				INNER JOIN (SELECT gymmember.pokemon_uid, gymmember.gym_id FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
456 456
 				ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid) AS actives_pokemons ON actives_pokemons.trainer_name = trainer.name
457
-				GROUP BY trainer.name " . $where . $order . $limit;
457
+				GROUP BY trainer.name " . $where.$order.$limit;
458 458
 
459 459
 		$result = $this->mysqli->query($req);
460 460
 		$trainers = array();
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		return $data;
476 476
 	}
477 477
 
478
-	private function getTrainerActivePokemon($trainer_name){
478
+	private function getTrainerActivePokemon($trainer_name) {
479 479
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active
480 480
 					FROM gympokemon INNER JOIN
481 481
 					(SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 		return $pokemons;
491 491
 	}
492 492
 
493
-	private function getTrainerInactivePokemon($trainer_name){
493
+	private function getTrainerInactivePokemon($trainer_name) {
494 494
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active
495 495
 					FROM gympokemon LEFT JOIN
496 496
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                     JOIN spawnpoint s ON p.spawnpoint_id = s.id
545 545
                     " . $where."
546 546
                 ) x
547
-				" . $where . "
547
+				" . $where."
548 548
 				ORDER BY last_timestamp DESC
549 549
                 LIMIT 0,1";
550 550
 		$result = $this->mysqli->query($req);
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 			          FROM pokemon p 
587 587
 			          INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) 
588 588
 			          WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL 24 HOUR 
589
-			          " . $pokemon_exclude_sql . " 
589
+			          " . $pokemon_exclude_sql." 
590 590
 			          GROUP BY p.spawnpoint_id, p.pokemon_id 
591 591
 			          HAVING COUNT(p.pokemon_id) >= 6 
592 592
 			          ORDER BY p.pokemon_id";
Please login to merge, or discard this patch.
Braces   +84 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,12 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class QueryManagerMysqlRocketmap extends QueryManagerMysql {
3
+final class QueryManagerMysqlRocketmap extends QueryManagerMysql
4
+{
4 5
 
5
-	public function __construct() {
6
+	public function __construct()
7
+	{
6 8
 		parent::__construct();
7 9
 	}
8 10
 
9
-	public function __destruct() {
11
+	public function __destruct()
12
+	{
10 13
 		parent::__destruct();
11 14
 	}
12 15
 
@@ -14,7 +17,8 @@  discard block
 block discarded – undo
14 17
 	// Tester
15 18
 	///////////
16 19
 	
17
-	function testTotalPokemon() {
20
+	function testTotalPokemon()
21
+	{
18 22
 		$req = "SELECT COUNT(*) as total FROM pokemon";
19 23
 		$result = $this->mysqli->query($req);
20 24
 		if (!is_object($result)) {
@@ -30,7 +34,8 @@  discard block
 block discarded – undo
30 34
 		return 0;
31 35
 	}
32 36
 	
33
-	function testTotalGyms() {
37
+	function testTotalGyms()
38
+	{
34 39
 		$req = "SELECT COUNT(*) as total FROM gym";
35 40
 		$result = $this->mysqli->query($req);
36 41
 		if (!is_object($result)) {
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
 		return 0;
47 52
 	}
48 53
 	
49
-	function testTotalPokestops() {
54
+	function testTotalPokestops()
55
+	{
50 56
 		$req = "SELECT COUNT(*) as total FROM pokestop";
51 57
 		$result = $this->mysqli->query($req);
52 58
 		if (!is_object($result)) {
@@ -67,42 +73,48 @@  discard block
 block discarded – undo
67 73
 	// Homepage
68 74
 	/////////////
69 75
 	
70
-	function getTotalPokemon() {
76
+	function getTotalPokemon()
77
+	{
71 78
 		$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
72 79
 		$result = $this->mysqli->query($req);
73 80
 		$data = $result->fetch_object();
74 81
 		return $data;
75 82
 	}
76 83
 	
77
-	function getTotalLures() {
84
+	function getTotalLures()
85
+	{
78 86
 		$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
79 87
 		$result = $this->mysqli->query($req);
80 88
 		$data = $result->fetch_object();
81 89
 		return $data;
82 90
 	}
83 91
 	
84
-	function getTotalGyms() {
92
+	function getTotalGyms()
93
+	{
85 94
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
86 95
 		$result = $this->mysqli->query($req);
87 96
 		$data = $result->fetch_object();
88 97
 		return $data;
89 98
 	}
90 99
 	
91
-	function getTotalRaids() {
100
+	function getTotalRaids()
101
+	{
92 102
 		$req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND  end >= UTC_TIMESTAMP()";
93 103
 		$result = $this->mysqli->query($req);
94 104
 		$data = $result->fetch_object();
95 105
 		return $data;
96 106
 	}
97 107
 	
98
-	function getTotalGymsForTeam($team_id) {
108
+	function getTotalGymsForTeam($team_id)
109
+	{
99 110
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'";
100 111
 		$result = $this->mysqli->query($req);
101 112
 		$data = $result->fetch_object();
102 113
 		return $data;
103 114
 	}
104 115
 	
105
-	function getRecentAll() {
116
+	function getRecentAll()
117
+	{
106 118
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
107 119
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
108 120
 					FROM pokemon
@@ -118,7 +130,8 @@  discard block
 block discarded – undo
118 130
 		return $data;
119 131
 	}
120 132
 	
121
-	function getRecentMythic($mythic_pokemons) {
133
+	function getRecentMythic($mythic_pokemons)
134
+	{
122 135
 		$req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real,
123 136
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
124 137
 					FROM pokemon
@@ -139,14 +152,16 @@  discard block
 block discarded – undo
139 152
 	// Single Pokemon
140 153
 	///////////////////
141 154
 	
142
-	function getGymsProtectedByPokemon($pokemon_id) {
155
+	function getGymsProtectedByPokemon($pokemon_id)
156
+	{
143 157
 		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'";
144 158
 		$result = $this->mysqli->query($req);
145 159
 		$data = $result->fetch_object();
146 160
 		return $data;
147 161
 	}
148 162
 	
149
-	function getPokemonLastSeen($pokemon_id) {
163
+	function getPokemonLastSeen($pokemon_id)
164
+	{
150 165
 		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
151 166
 							FROM pokemon
152 167
 							WHERE pokemon_id = '".$pokemon_id."'
@@ -157,7 +172,8 @@  discard block
 block discarded – undo
157 172
 		return $data;
158 173
 	}
159 174
 
160
-	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
175
+	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
176
+	{
161 177
 		$req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude,
162 178
 							cp, individual_attack, individual_defense, individual_stamina,
163 179
 							ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form
@@ -175,7 +191,8 @@  discard block
 block discarded – undo
175 191
 		return $top;
176 192
 	}
177 193
 
178
-	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
194
+	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
195
+	{
179 196
 		$trainer_blacklist = "";
180 197
 		if (!empty(self::$config->system->trainer_blacklist)) {
181 198
 			$trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -197,7 +214,8 @@  discard block
 block discarded – undo
197 214
 		return $toptrainer;
198 215
 	}
199 216
 
200
-	public function getPokemonHeatmap($pokemon_id, $start, $end) {
217
+	public function getPokemonHeatmap($pokemon_id, $start, $end)
218
+	{
201 219
 		$where = " WHERE pokemon_id = ".$pokemon_id." "
202 220
 			. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
203 221
 		$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
@@ -209,7 +227,8 @@  discard block
 block discarded – undo
209 227
 		return $points;
210 228
 	}
211 229
 
212
-	public function getPokemonGraph($pokemon_id) {
230
+	public function getPokemonGraph($pokemon_id)
231
+	{
213 232
 		$req = "SELECT COUNT(*) AS total,
214 233
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_hour
215 234
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 100000) AS pokemonFiltered
@@ -226,7 +245,8 @@  discard block
 block discarded – undo
226 245
 		return $array;
227 246
 	}
228 247
 
229
-	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) {
248
+	public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
249
+	{
230 250
 		$inmap_pkms_filter = "";
231 251
 		$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
232 252
 
@@ -260,14 +280,16 @@  discard block
 block discarded – undo
260 280
 		return $spawns;
261 281
 	}
262 282
 
263
-	public function getPokemonSliederMinMax() {
283
+	public function getPokemonSliederMinMax()
284
+	{
264 285
 		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
265 286
 		$result = $this->mysqli->query($req);
266 287
 		$data = $result->fetch_object();
267 288
 		return $data;
268 289
 	}
269 290
 
270
-	public function getMapsCoords() {
291
+	public function getMapsCoords()
292
+	{
271 293
 		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
272 294
 		$result = $this->mysqli->query($req);
273 295
 		$data = $result->fetch_object();
@@ -279,14 +301,16 @@  discard block
 block discarded – undo
279 301
 	// Pokestops
280 302
 	//////////////
281 303
 
282
-	function getTotalPokestops() {
304
+	function getTotalPokestops()
305
+	{
283 306
 		$req = "SELECT COUNT(*) as total FROM pokestop";
284 307
 		$result = $this->mysqli->query($req);
285 308
 		$data = $result->fetch_object();
286 309
 		return $data;
287 310
 	}
288 311
 
289
-	public function getAllPokestops() {
312
+	public function getAllPokestops()
313
+	{
290 314
 		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".self::$time_offset."')) AS lure_expiration_real FROM pokestop";
291 315
 		$result = $this->mysqli->query($req);
292 316
 		$pokestops = array();
@@ -301,7 +325,8 @@  discard block
 block discarded – undo
301 325
 	// Gyms
302 326
 	/////////
303 327
 
304
-	function getTeamGuardians($team_id) {
328
+	function getTeamGuardians($team_id)
329
+	{
305 330
 		$req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
306 331
 		$result = $this->mysqli->query($req);
307 332
 		$datas = array();
@@ -311,14 +336,16 @@  discard block
 block discarded – undo
311 336
 		return $datas;
312 337
 	}
313 338
 
314
-	function getOwnedAndPoints($team_id) {
339
+	function getOwnedAndPoints($team_id)
340
+	{
315 341
 		$req 	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
316 342
 		$result = $this->mysqli->query($req);
317 343
 		$data = $result->fetch_object();
318 344
 		return $data;
319 345
 	}
320 346
 
321
-	function getAllGyms() {
347
+	function getAllGyms()
348
+	{
322 349
 		$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
323 350
 		$result = $this->mysqli->query($req);
324 351
 		$gyms = array();
@@ -328,7 +355,8 @@  discard block
 block discarded – undo
328 355
 		return $gyms;
329 356
 	}
330 357
 
331
-	public function getGymData($gym_id) {
358
+	public function getGymData($gym_id)
359
+	{
332 360
 		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
333 361
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, gym.total_cp AS total_cp, (6 - gym.slots_available) AS level
334 362
 					FROM gymdetails
@@ -339,7 +367,8 @@  discard block
 block discarded – undo
339 367
 		return $data;
340 368
 	}
341 369
 
342
-	public function getGymDefenders($gym_id) {
370
+	public function getGymDefenders($gym_id)
371
+	{
343 372
 		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
344 373
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
345 374
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
@@ -358,7 +387,8 @@  discard block
 block discarded – undo
358 387
 	// Raids
359 388
 	///////////
360 389
 
361
-	public function getAllRaids($page) {
390
+	public function getAllRaids($page)
391
+	{
362 392
 		$limit = " LIMIT ".($page * 10).",10";
363 393
 		$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".self::$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".self::$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".self::$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".self::$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
364 394
 					JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
@@ -378,7 +408,8 @@  discard block
 block discarded – undo
378 408
 	// Trainers
379 409
 	//////////////
380 410
 
381
-	public function getTrainers($trainer_name, $team, $page, $ranking) {
411
+	public function getTrainers($trainer_name, $team, $page, $ranking)
412
+	{
382 413
 		$trainers = $this->getTrainerData($trainer_name, $team, $page, $ranking);
383 414
 		foreach ($trainers as $trainer) {
384 415
 
@@ -403,7 +434,8 @@  discard block
 block discarded – undo
403 434
 		return $trainers;
404 435
 	}
405 436
 
406
-	public function getTrainerLevelCount($team_id) {
437
+	public function getTrainerLevelCount($team_id)
438
+	{
407 439
 		$req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'";
408 440
 		if (!empty(self::$config->system->trainer_blacklist)) {
409 441
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -424,7 +456,8 @@  discard block
 block discarded – undo
424 456
 		return $levelData;
425 457
 	}
426 458
 
427
-	private function getTrainerData($trainer_name, $team, $page, $ranking) {
459
+	private function getTrainerData($trainer_name, $team, $page, $ranking)
460
+	{
428 461
 		$where = "";
429 462
 
430 463
 		if (!empty(self::$config->system->trainer_blacklist)) {
@@ -465,7 +498,8 @@  discard block
 block discarded – undo
465 498
 		return $trainers;
466 499
 	}
467 500
 
468
-	private function getTrainerLevelRating($level) {
501
+	private function getTrainerLevelRating($level)
502
+	{
469 503
 		$req = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$level;
470 504
 		if (!empty(self::$config->system->trainer_blacklist)) {
471 505
 			$req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
@@ -475,7 +509,8 @@  discard block
 block discarded – undo
475 509
 		return $data;
476 510
 	}
477 511
 
478
-	private function getTrainerActivePokemon($trainer_name){
512
+	private function getTrainerActivePokemon($trainer_name)
513
+	{
479 514
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active
480 515
 					FROM gympokemon INNER JOIN
481 516
 					(SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -490,7 +525,8 @@  discard block
 block discarded – undo
490 525
 		return $pokemons;
491 526
 	}
492 527
 
493
-	private function getTrainerInactivePokemon($trainer_name){
528
+	private function getTrainerInactivePokemon($trainer_name)
529
+	{
494 530
 		$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active
495 531
 					FROM gympokemon LEFT JOIN
496 532
 					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
@@ -510,7 +546,8 @@  discard block
 block discarded – undo
510 546
 	// Cron
511 547
 	/////////
512 548
 
513
-	public function getPokemonCountsActive() {
549
+	public function getPokemonCountsActive()
550
+	{
514 551
 		$req = "SELECT pokemon_id, COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP() GROUP BY pokemon_id";
515 552
 		$result = $this->mysqli->query($req);
516 553
 		$counts = array();
@@ -520,7 +557,8 @@  discard block
 block discarded – undo
520 557
 		return $counts;
521 558
 	}
522 559
 
523
-	public function getPoekmonCountsLastDay() {
560
+	public function getPoekmonCountsLastDay()
561
+	{
524 562
 		$req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day
525 563
 					FROM pokemon
526 564
 					WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY
@@ -534,7 +572,8 @@  discard block
 block discarded – undo
534 572
 		return $counts;
535 573
 	}
536 574
 
537
-	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
575
+	public function getPokemonSinceLastUpdate($pokemon_id, $last_update)
576
+	{
538 577
 		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'";
539 578
 		$req = "SELECT count, (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) as last_timestamp, (CONVERT_TZ(p.disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, p.latitude, p.longitude 
540 579
 				FROM pokemon p
@@ -552,7 +591,8 @@  discard block
 block discarded – undo
552 591
 		return $data;
553 592
 	}
554 593
 
555
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
594
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
595
+	{
556 596
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'";
557 597
 		$req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count
558 598
                 FROM raid r
@@ -570,14 +610,16 @@  discard block
 block discarded – undo
570 610
 		return $data;
571 611
 	}
572 612
 
573
-	public function getCaptchaCount() {
613
+	public function getCaptchaCount()
614
+	{
574 615
 		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";
575 616
 		$result = $this->mysqli->query($req);
576 617
 		$data = $result->fetch_object();
577 618
 		return $data;
578 619
 	}
579 620
 
580
-	public function getNestData() {
621
+	public function getNestData()
622
+	{
581 623
 		$pokemon_exclude_sql = "";
582 624
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
583 625
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
Please login to merge, or discard this patch.