Code Duplication    Length = 38-38 lines in 2 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

@@ 462-499 (lines=38) @@
459
		return $pokemons;
460
	}
461
462
	public function getHistoryForGym($page, $gym_id)
463
	{
464
		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
465
			$pageSize = 25;
466
		} else {
467
			$pageSize = 10;
468
		}
469
		$req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, FROM_UNIXTIME(fs.last_modified) as last_modified, last_modified as last_modified_real
470
					FROM fort_sightings fs
471
					LEFT JOIN forts f ON f.id = fs.fort_id
472
					WHERE f.id = '". $gym_id ."'
473
					ORDER BY fs.last_modified DESC
474
					LIMIT ".($page * $pageSize).",".($pageSize+1);
475
		$result = $this->mysqli->query($req);
476
		$history = array();
477
		$count = 0;
478
		while ($data = $result->fetch_object()) {
479
			$count++;
480
			if ($data->total_cp == 0) {
481
				$data->pokemon = array();
482
				$data->pokemon_count = 0;
483
				$data->pokemon_uids = "";
484
			} else {
485
				$data->pokemon = $this->getHistoryForGymPokemon($gym_id, $data->last_modified_real);
486
				$data->pokemon_count = count($data->pokemon);
487
				$data->pokemon_uids = implode(",", array_keys($data->pokemon));
488
			}
489
			if ($data->total_cp === 0 || $data->pokemon_count !== 0) {
490
				$history[] = $data;
491
			}
492
		}
493
		if ($count !== ($pageSize + 1)) {
494
			$last_page = true;
495
		} else {
496
			$last_page = false;
497
		}
498
		return array("last_page" => $last_page, "data" => $history);
499
	}
500
501
	private function getHistoryForGymPokemon($gym_id, $last_modified)
502
	{

core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 1 location

@@ 447-484 (lines=38) @@
444
		return $pokemons;
445
	}
446
447
	public function getHistoryForGym($page, $gym_id)
448
	{
449
		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
450
			$pageSize = 25;
451
		} else {
452
			$pageSize = 10;
453
		}
454
		$req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, TO_TIMESTAMP(fs.last_modified) as last_modified, last_modified as last_modified_real
455
					FROM fort_sightings fs
456
					LEFT JOIN forts f ON f.id = fs.fort_id
457
					WHERE f.id = '". $gym_id ."'
458
					ORDER BY fs.last_modified DESC
459
					LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize);
460
		$result = $this->mysqli->query($req);
461
		$history = array();
462
		$count = 0;
463
		while ($data = $result->fetch_object()) {
464
			$count++;
465
			if ($data->total_cp == 0) {
466
				$data->pokemon = array();
467
				$data->pokemon_count = 0;
468
				$data->pokemon_uids = "";
469
			} else {
470
				$data->pokemon = $this->getHistoryForGymPokemon($gym_id, $data->last_modified_real);
471
				$data->pokemon_count = count($data->pokemon);
472
				$data->pokemon_uids = implode(",", array_keys($data->pokemon));
473
			}
474
			if ($data->total_cp === 0 || $data->pokemon_count !== 0) {
475
				$history[] = $data;
476
			}
477
		}
478
		if ($count !== ($pageSize + 1)) {
479
			$last_page = true;
480
		} else {
481
			$last_page = false;
482
		}
483
		return array("last_page" => $last_page, "data" => $history);
484
	}
485
486
	private function getHistoryForGymPokemon($gym_id, $last_modified)
487
	{