Code Duplication    Length = 15-17 lines in 4 locations

core/process/queries/QueryManagerMysqlRocketmap.php 2 locations

@@ 640-654 (lines=15) @@
637
		return $counts;
638
	}
639
640
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
641
		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'";
642
		$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 
643
				FROM pokemon p
644
				JOIN spawnpoint s ON p.spawnpoint_id = s.id
645
				JOIN (SELECT count(*) as count
646
                    FROM pokemon p
647
                    JOIN spawnpoint s ON p.spawnpoint_id = s.id
648
                    " . $where."
649
                ) x
650
				" . $where . "
651
				ORDER BY last_timestamp DESC
652
                LIMIT 0,1";
653
		$result = $this->mysqli->query($req);
654
		$data = $result->fetch_object();
655
		return $data;
656
	}
657
@@ 658-674 (lines=17) @@
655
		return $data;
656
	}
657
658
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
659
		$where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'";
660
		$req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count
661
                FROM raid r
662
                JOIN gym g
663
                JOIN (SELECT count(*) as count
664
                    FROM raid
665
                    " . $where."
666
                ) x
667
                ON r.gym_id = g.gym_id
668
                " . $where."
669
                ORDER BY start DESC
670
                LIMIT 0,1";
671
		$result = $this->mysqli->query($req);
672
		$data = $result->fetch_object();
673
		return $data;
674
	}
675
676
	public function getCaptchaCount() {
677
		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";

core/process/queries/QueryManagerMysqlMonocleAlternate.php 2 locations

@@ 653-667 (lines=15) @@
650
		return $counts;
651
	}
652
653
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
654
		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) > '".$last_update."'";
655
		$req = "SELECT count, p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) AS last_timestamp, (FROM_UNIXTIME(p.expire_timestamp)) AS disappear_time_real, p.lat as latitude, p.lon as longitude
656
					FROM sightings p
657
					LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id
658
					JOIN (SELECT COUNT(*) AS count
659
						FROM sightings p
660
						LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id
661
                    	" . $where."
662
                    ) x
663
					" . $where . "
664
					ORDER BY last_timestamp DESC
665
					LIMIT 0 , 1";
666
		$result = $this->mysqli->query($req);
667
		$data = $result->fetch_object();
668
		return $data;
669
	}
670
@@ 671-687 (lines=17) @@
668
		return $data;
669
	}
670
671
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
672
		$where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'";
673
		$req = "SELECT time_battle AS start_timestamp, time_end as end, (FROM_UNIXTIME(time_end)) AS end_time_real, lat as latitude, lon as longitude, count
674
					FROM raids r
675
					JOIN forts g
676
					JOIN (SELECT COUNT(*) AS count
677
						FROM raids
678
                    	" . $where."
679
                    ) x 
680
					ON r.fort_id = g.id
681
                    " . $where . "
682
                    ORDER BY time_battle DESC
683
					LIMIT 0 , 1";
684
		$result = $this->mysqli->query($req);
685
		$data = $result->fetch_object();
686
		return $data;
687
	}
688
689
	public function getCaptchaCount() {
690
		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";