Code Duplication    Length = 34-34 lines in 3 locations

core/process/queries/QueryManagerMysqlMonocleAlternate.php 1 location

@@ 414-447 (lines=34) @@
411
	// Gym History
412
	////////////////
413
414
	public function getGymHistories($gym_name, $team, $page, $ranking)
415
	{
416
		$where = "";
417
		if (isset($gym_name) && $gym_name != '') {
418
			$where = " WHERE name LIKE '%".$gym_name."%'";
419
		}
420
		if (isset($team) && $team != '') {
421
			$where .= ($where === "" ? " WHERE" : " AND")." fs.team = ".$team;
422
		}
423
		switch ($ranking) {
424
			case 1:
425
				$order = " ORDER BY name, last_modified DESC";
426
				break;
427
			case 2:
428
				$order = " ORDER BY total_cp DESC, last_modified DESC";
429
				break;
430
			default:
431
				$order = " ORDER BY last_modified DESC, name";
432
		}
433
434
		$limit = " LIMIT ".($page * 10).",10";
435
436
		$req = "SELECT f.id as gym_id, fs.total_cp, f.name, fs.team as team_id, (6 - slots_available) as pokemon_count, FROM_UNIXTIME(last_modified) AS last_modified
437
			FROM forts f
438
			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
439
			".$where.$order.$limit;
440
		$result = $this->mysqli->query($req);
441
		$gym_history = array();
442
		while ($data = $result->fetch_object()) {
443
			$gym_history[] = $data;
444
		}
445
		return $gym_history;
446
	}
447
448
	public function getGymHistoriesPokemon($gym_id)
449
	{
450
		$req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name

core/process/queries/QueryManagerMysqlRocketmap.php 1 location

@@ 378-411 (lines=34) @@
375
	// Gym History
376
	////////////////
377
378
	public function getGymHistories($gym_name, $team, $page, $ranking) {
379
		$where = '';
380
		if (isset($gym_name) && $gym_name != '') {
381
			$where = " WHERE name LIKE '%".$gym_name."%'";
382
		}
383
		if (isset($team) && $team != '') {
384
			$where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team;
385
		}
386
		switch ($ranking) {
387
			case 1:
388
				$order = " ORDER BY name, last_modified DESC";
389
				break;
390
			case 2:
391
				$order = " ORDER BY total_cp DESC, last_modified DESC";
392
				break;
393
			default:
394
				$order = " ORDER BY last_modified DESC, name";
395
		}
396
397
		$limit = " LIMIT ".($page * 10).",10";
398
399
		$req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '" . self::$time_offset . "')) as last_modified
400
				FROM gymdetails
401
				LEFT JOIN gym
402
				ON gymdetails.gym_id = gym.gym_id
403
				".$where.$order.$limit;
404
405
		$result = $this->mysqli->query($req);
406
		$gym_history = array();
407
		while ($data = $result->fetch_object()) {
408
			$gym_history[] = $data;
409
		}
410
		return $gym_history;
411
	}
412
413
	public function getGymHistoriesPokemon($gym_id) {
414
		$req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name

core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 1 location

@@ 398-431 (lines=34) @@
395
	// Gym History
396
	////////////////
397
398
	public function getGymHistories($gym_name, $team, $page, $ranking)
399
	{
400
		$where = "";
401
		if (isset($gym_name) && $gym_name != '') {
402
			$where = " WHERE name LIKE '%".$gym_name."%'";
403
		}
404
		if (isset($team) && $team != '') {
405
			$where .= ($where === "" ? " WHERE" : " AND")." fs.team = ".$team;
406
		}
407
		switch ($ranking) {
408
			case 1:
409
				$order = " ORDER BY name, last_modified DESC";
410
				break;
411
			case 2:
412
				$order = " ORDER BY total_cp DESC, last_modified DESC";
413
				break;
414
			default:
415
				$order = " ORDER BY last_modified DESC, name";
416
		}
417
418
		$limit = " LIMIT 10 OFFSET ".($page * 10);
419
420
		$req = "SELECT f.id as gym_id, fs.total_cp, f.name, fs.team as team_id, (6 - slots_available) as pokemon_count, TO_TIMESTAMP(last_modified) AS last_modified
421
			FROM forts f
422
			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
423
			".$where.$order.$limit;
424
425
		$result = $this->mysqli->query($req);
426
		$gym_history = array();
427
		while ($data = $result->fetch_object()) {
428
			$gym_history[] = $data;
429
		}
430
		return $gym_history;
431
	}
432
433
	public function getGymHistoriesPokemon($gym_id)
434
	{