Code Duplication    Length = 6-10 lines in 6 locations

core/process/queries/QueryManagerMonocleHydro.php 3 locations

@@ 137-142 (lines=6) @@
134
	// Single Pokemon
135
	///////////////////
136
137
	function getGymsProtectedByPokemon($pokemon_id) {
138
		$req = "SELECT COUNT(DISTINCT(fort_id)) AS total FROM fort_sightings WHERE guard_pokemon_id = '".$pokemon_id."'";
139
		$result = $this->mysqli->query($req);
140
		$data = $result->fetch_object();
141
		return $data;
142
	}
143
144
	function getPokemonLastSeen($pokemon_id) {
145
		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
@@ 144-153 (lines=10) @@
141
		return $data;
142
	}
143
144
	function getPokemonLastSeen($pokemon_id) {
145
		$req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
146
                FROM sightings
147
                WHERE pokemon_id = '".$pokemon_id."'
148
                ORDER BY expire_timestamp DESC
149
                LIMIT 0,1";
150
		$result = $this->mysqli->query($req);
151
		$data = $result->fetch_object();
152
		return $data;
153
	}
154
155
	function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) {
156
		$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,
@@ 427-434 (lines=8) @@
424
		return $counts;
425
	}
426
427
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
428
		$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
429
					FROM sightings
430
					WHERE pokemon_id = '".$pokemon_id."' && expire_timestamp > '".$last_update."'";
431
		$result = $this->mysqli->query($req);
432
		$data = $result->fetch_object();
433
		return $data;
434
	}
435
436
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
437
		$where = "WHERE pokemon_id = '".$pokemon_id."' && time_battle > '".$last_update."'";

core/process/queries/QueryManagerRocketmap.php 3 locations

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