Code Duplication    Length = 6-10 lines in 6 locations

core/process/queries/QueryManagerMonocleHydro.php 3 locations

@@ 141-146 (lines=6) @@
138
	// Single Pokemon
139
	///////////////////
140
141
	function getGymsProtectedByPokemon($pokemon_id) {
142
		$req = "SELECT COUNT(DISTINCT(fort_id)) AS total FROM fort_sightings WHERE guard_pokemon_id = '".$pokemon_id."'";
143
		$result = $this->mysqli->query($req);
144
		$data = $result->fetch_object();
145
		return $data;
146
	}
147
148
	function getPokemonLastSeen($pokemon_id) {
149
		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
@@ 148-157 (lines=10) @@
145
		return $data;
146
	}
147
148
	function getPokemonLastSeen($pokemon_id) {
149
		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
150
                FROM sightings
151
                WHERE pokemon_id = '".$pokemon_id."'
152
                ORDER BY expire_timestamp DESC
153
                LIMIT 0,1";
154
		$result = $this->mysqli->query($req);
155
		$data = $result->fetch_object();
156
		return $data;
157
	}
158
159
	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
160
		$req = "SELECT FROM_UNIXTIME(expire_timestamp+0) AS distime, pokemon_id+0 as pokemon_id, FROM_UNIXTIME(expire_timestamp+0) as disappear_time, lat as latitude, lon as longitude,
@@ 431-438 (lines=8) @@
428
		return $counts;
429
	}
430
431
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
432
		$req = "SELECT COUNT(*) AS count, MAX(expire_timestamp) AS last_timestamp, (FROM_UNIXTIME(MAX(expire_timestamp))) AS disappear_time_real, lat as latitude, lon as longitude
433
					FROM sightings
434
					WHERE pokemon_id = '".$pokemon_id."' && expire_timestamp > '".$last_update."'";
435
		$result = $this->mysqli->query($req);
436
		$data = $result->fetch_object();
437
		return $data;
438
	}
439
440
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
441
		$where = "WHERE pokemon_id = '".$pokemon_id."' && time_battle > '".$last_update."'";

core/process/queries/QueryManagerRocketmap.php 3 locations

@@ 142-147 (lines=6) @@
139
	// Single Pokemon
140
	///////////////////
141
	
142
	function getGymsProtectedByPokemon($pokemon_id) {
143
		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'";
144
		$result = $this->mysqli->query($req);
145
		$data = $result->fetch_object();
146
		return $data;
147
	}
148
	
149
	function getPokemonLastSeen($pokemon_id) {
150
		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
@@ 149-158 (lines=10) @@
146
		return $data;
147
	}
148
	
149
	function getPokemonLastSeen($pokemon_id) {
150
		$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude
151
							FROM pokemon
152
							WHERE pokemon_id = '".$pokemon_id."'
153
							ORDER BY disappear_time DESC
154
							LIMIT 0,1";
155
		$result = $this->mysqli->query($req);
156
		$data = $result->fetch_object();
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,
@@ 538-545 (lines=8) @@
535
		return $counts;
536
	}
537
538
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
539
		$req = "SELECT COUNT(*) as count, UNIX_TIMESTAMP(MAX(disappear_time)) as last_timestamp, (CONVERT_TZ(MAX(disappear_time), '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude 
540
				FROM pokemon 
541
				WHERE pokemon_id = '".$pokemon_id."' && UNIX_TIMESTAMP(disappear_time) > '".$last_update."'";
542
		$result = $this->mysqli->query($req);
543
		$data = $result->fetch_object();
544
		return $data;
545
	}
546
547
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
548
		$where = "WHERE pokemon_id = '".$pokemon_id."' && UNIX_TIMESTAMP(start) > '".$last_update."'";