Code Duplication    Length = 14-17 lines in 4 locations

core/process/queries/QueryManagerMysqlRocketmap.php 3 locations

@@ 160-176 (lines=17) @@
157
		return $data;
158
	}
159
160
	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
161
		$req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude,
162
							cp, individual_attack, individual_defense, individual_stamina,
163
							ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form
164
							FROM pokemon
165
							WHERE pokemon_id = '".$pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
166
							ORDER BY $top_order_by $top_direction, disappear_time DESC
167
							LIMIT 0,50";
168
169
		$result = $this->mysqli->query($req);
170
		$top = array();
171
		while ($data = $result->fetch_object()) {
172
			$top[] = $data;
173
		}
174
		return $top;
175
	}
176
177
	function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) {
178
		$trainer_blacklist = "";
179
		if (!empty(self::$config->system->trainer_blacklist)) {
@@ 559-572 (lines=14) @@
556
		return $data;
557
	}
558
559
	private function getTrainerActivePokemon($trainer_name){
560
		$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
561
					FROM gympokemon INNER JOIN
562
					(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
563
					ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid
564
					WHERE gympokemon.trainer_name='".$trainer_name."'
565
					ORDER BY gympokemon.cp DESC)";
566
		$result = $this->mysqli->query($req);
567
		$pokemons = array();
568
		while ($data = $result->fetch_object()) {
569
			$pokemons[] = $data;
570
		}
571
		return $pokemons;
572
	}
573
574
	private function getTrainerInactivePokemon($trainer_name){
575
		$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
@@ 574-587 (lines=14) @@
571
		return $pokemons;
572
	}
573
574
	private function getTrainerInactivePokemon($trainer_name){
575
		$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
576
					FROM gympokemon LEFT JOIN
577
					(SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember
578
					ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid
579
					WHERE filtered_gymmember.pokemon_uid IS NULL AND gympokemon.trainer_name='".$trainer_name."'
580
					ORDER BY gympokemon.cp DESC)";
581
		$result = $this->mysqli->query($req);
582
		$pokemons = array();
583
		while ($data = $result->fetch_object()) {
584
			$pokemons[] = $data;
585
		}
586
		return $pokemons;
587
	}
588
589
590
	/////////

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

@@ 365-379 (lines=15) @@
362
	// Raids
363
	///////////
364
365
	public function getAllRaids($page) {
366
		$limit = " LIMIT ".($page * 10).",10";
367
		$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, FROM_UNIXTIME(r.time_spawn) AS spawn, FROM_UNIXTIME(r.time_battle) AS start, FROM_UNIXTIME(r.time_end) AS end, FROM_UNIXTIME(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude 
368
					FROM raids r 
369
					JOIN forts f ON f.id = r.fort_id 
370
					LEFT JOIN fort_sightings fs ON fs.fort_id = r.fort_id 
371
					WHERE r.time_end > UNIX_TIMESTAMP() 
372
					ORDER BY r.level DESC, r.time_battle" . $limit;
373
		$result = $this->mysqli->query($req);
374
		$raids = array();
375
		while ($data = $result->fetch_object()) {
376
			$raids[] = $data;
377
		}
378
		return $raids;
379
	}
380
381
382