Code Duplication    Length = 15-17 lines in 4 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 2 locations

@@ 429-443 (lines=15) @@
426
		return $counts;
427
	}
428
429
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
430
		$where = "WHERE pokemon_id = '".$pokemon_id."' AND id > '".$last_update."'";
431
		$req = "SELECT count, id AS last_timestamp, (FROM_UNIXTIME(expire_timestamp)) AS disappear_time_real, lat as latitude, lon as longitude
432
					FROM sightings
433
					JOIN (SELECT COUNT(*) AS count
434
						FROM sightings
435
                    	" . $where."
436
                    ) x
437
					" . $where . "
438
					ORDER BY expire_timestamp DESC
439
					LIMIT 0 , 1";
440
		$result = $this->mysqli->query($req);
441
		$data = $result->fetch_object();
442
		return $data;
443
	}
444
445
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
446
		$where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'";
@@ 445-461 (lines=17) @@
442
		return $data;
443
	}
444
445
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
446
		$where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'";
447
		$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
448
					FROM raids r
449
					JOIN forts g
450
					JOIN (SELECT COUNT(*) AS count
451
						FROM raids
452
                    	" . $where."
453
                    ) x 
454
					ON r.fort_id = g.id
455
                    " . $where . "
456
                    ORDER BY time_battle DESC
457
					LIMIT 0 , 1";
458
		$result = $this->mysqli->query($req);
459
		$data = $result->fetch_object();
460
		return $data;
461
	}
462
463
	public function getCaptchaCount() {
464
		$req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL";

core/process/queries/QueryManagerMysqlRocketmap.php 2 locations

@@ 536-550 (lines=15) @@
533
		return $counts;
534
	}
535
536
	public function getPokemonSinceLastUpdate($pokemon_id, $last_update) {
537
		$where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'";
538
		$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 
539
				FROM pokemon p
540
				JOIN spawnpoint s ON p.spawnpoint_id = s.id
541
				JOIN (SELECT count(*) as count
542
                    FROM pokemon p
543
                    JOIN spawnpoint s ON p.spawnpoint_id = s.id
544
                    " . $where."
545
                ) x
546
				" . $where . "
547
				ORDER BY last_timestamp DESC
548
                LIMIT 0,1";
549
		$result = $this->mysqli->query($req);
550
		$data = $result->fetch_object();
551
		return $data;
552
	}
553
@@ 554-570 (lines=17) @@
551
		return $data;
552
	}
553
554
	public function getRaidsSinceLastUpdate($pokemon_id, $last_update) {
555
		$where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'";
556
		$req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count
557
                FROM raid r
558
                JOIN gym g
559
                JOIN (SELECT count(*) as count
560
                    FROM raid
561
                    " . $where."
562
                ) x
563
                ON r.gym_id = g.gym_id
564
                " . $where."
565
                ORDER BY start DESC
566
                LIMIT 0,1";
567
		$result = $this->mysqli->query($req);
568
		$data = $result->fetch_object();
569
		return $data;
570
	}
571
572
	public function getCaptchaCount() {
573
		$req = "SELECT SUM(accounts_captcha) AS total FROM mainworker";