Failed Conditions
Pull Request — master (#353)
by Florian
02:31
created
core/process/queries/QueryManager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/../../../config.php';
4
-include_once __DIR__ . '/QueryManagerMysql.php';
5
-include_once __DIR__ . '/QueryManagerPostgresql.php';
3
+include_once __DIR__.'/../../../config.php';
4
+include_once __DIR__.'/QueryManagerMysql.php';
5
+include_once __DIR__.'/QueryManagerPostgresql.php';
6 6
 
7 7
 abstract class QueryManager {
8 8
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 		if (self::$current == null) {
17 17
 
18
-			$variables = realpath(dirname(__FILE__)) . '/../../json/variables.json';
18
+			$variables = realpath(dirname(__FILE__)).'/../../json/variables.json';
19 19
 			self::$config = json_decode(file_get_contents($variables));
20 20
 
21 21
 			include_once(SYS_PATH.'/core/process/timezone.loader.php');
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		}
38 38
 		return self::$current;
39 39
 	}
40
-	private function __construct(){}
40
+	private function __construct() {}
41 41
 
42 42
 	// Misc
43 43
 	abstract public function getEcapedString($string);
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,13 +4,15 @@  discard block
 block discarded – undo
4 4
 include_once __DIR__ . '/QueryManagerMysql.php';
5 5
 include_once __DIR__ . '/QueryManagerPostgresql.php';
6 6
 
7
-abstract class QueryManager {
7
+abstract class QueryManager
8
+{
8 9
 
9 10
 	protected static $time_offset;
10 11
 	protected static $config;
11 12
 
12 13
 	private static $current;
13
-	public static function current() {
14
+	public static function current()
15
+	{
14 16
 		global $time_offset;
15 17
 
16 18
 		if (self::$current == null) {
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 		}
38 40
 		return self::$current;
39 41
 	}
40
-	private function __construct(){}
42
+	private function __construct()
43
+	{
44
+}
41 45
 
42 46
 	// Misc
43 47
 	abstract public function getEcapedString($string);
Please login to merge, or discard this patch.
core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 2 patches
Spacing   +13 added lines, -13 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 
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 	public function getNestData() {
470 470
 		$pokemon_exclude_sql = "";
471 471
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
472
-			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
472
+			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")";
473 473
 		}
474 474
 		$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
475 475
 			          FROM sightings p
476 476
 			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
477 477
 			          WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - 86400
478
-			          " . $pokemon_exclude_sql . "
478
+			          " . $pokemon_exclude_sql."
479 479
 			          GROUP BY p.spawn_id, p.pokemon_id
480 480
 			          HAVING COUNT(p.pokemon_id) >= 6
481 481
 			          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
 		$req = "SELECT COUNT(*) AS count, MAX(expire_timestamp) AS last_timestamp, (TO_TIMESTAMP(MAX(expire_timestamp))) AS disappear_time_real, lat as latitude, lon as longitude
437 472
 					FROM sightings
438 473
 					WHERE pokemon_id = '".$pokemon_id."' AND expire_timestamp > '".$last_update."'
@@ -442,7 +477,8 @@  discard block
 block discarded – undo
442 477
 		return $data;
443 478
 	}
444 479
 
445
-	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
480
+	public function getRaidsSinceLastUpdate($pokemon_id, $last_update)
481
+	{
446 482
 		$where = "WHERE pokemon_id = '".$pokemon_id."' AND time_battle > '".$last_update."'";
447 483
 		$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
448 484
 					FROM raids r
@@ -459,14 +495,16 @@  discard block
 block discarded – undo
459 495
 		return $data;
460 496
 	}
461 497
 
462
-	public function getCaptchaCount() {
498
+	public function getCaptchaCount()
499
+	{
463 500
 		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";
464 501
 		$result = pg_query($this->db, $req);
465 502
 		$data = pg_fetch_object($result);
466 503
 		return $data;
467 504
 	}
468 505
 
469
-	public function getNestData() {
506
+	public function getNestData()
507
+	{
470 508
 		$pokemon_exclude_sql = "";
471 509
 		if (!empty(self::$config->system->nest_exclude_pokemon)) {
472 510
 			$pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")";
Please login to merge, or discard this patch.