Code Duplication    Length = 15-17 lines in 4 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 2 locations

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

core/process/queries/QueryManagerMysqlRocketmap.php 2 locations

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