Code Duplication    Length = 38-38 lines in 2 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

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

core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 1 location

@@ 430-467 (lines=38) @@
427
		return $pokemons;
428
	}
429
430
	public function getHistoryForGym($page, $gym_id)
431
	{
432
		if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) {
433
			$pageSize = 25;
434
		} else {
435
			$pageSize = 10;
436
		}
437
		$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
438
					FROM fort_sightings fs
439
					LEFT JOIN forts f ON f.id = fs.fort_id
440
					WHERE f.id = '". $gym_id ."'
441
					ORDER BY fs.last_modified DESC
442
					LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize);
443
		$result = $this->mysqli->query($req);
444
		$history = array();
445
		$count = 0;
446
		while ($data = $result->fetch_object()) {
447
			$count++;
448
			if ($data->total_cp == 0) {
449
				$data->pokemon = array();
450
				$data->pokemon_count = 0;
451
				$data->pokemon_uids = "";
452
			} else {
453
				$data->pokemon = $this->getHistoryForGymPokemon($gym_id, $data->last_modified_real);
454
				$data->pokemon_count = count($data->pokemon);
455
				$data->pokemon_uids = implode(",", array_keys($data->pokemon));
456
			}
457
			if ($data->total_cp === 0 || $data->pokemon_count !== 0) {
458
				$history[] = $data;
459
			}
460
		}
461
		if ($count !== ($pageSize + 1)) {
462
			$last_page = true;
463
		} else {
464
			$last_page = false;
465
		}
466
		return array("last_page" => $last_page, "data" => $history);
467
	}
468
469
	private function getHistoryForGymPokemon($gym_id, $last_modified)
470
	{