Code Duplication    Length = 22-22 lines in 2 locations

core/process/queries/QueryManagerPostgresqlMonocleAlternate.php 2 locations

@@ 659-680 (lines=22) @@
656
        return $trainers;
657
    }
658
659
    public function getTrainerLevelRanking()
660
    {
661
        $exclue = '';
662
        if (!empty(self::$config->system->trainer_blacklist)) {
663
            $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
664
        }
665
        $req = 'SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL '.$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level';
666
        $result = pg_query($this->db, $req);
667
        $levelData = array();
668
        while ($data = pg_fetch_object($result)) {
669
            $levelData[$data->level] = $data->count;
670
        }
671
        for ($i = 5; $i <= 40; ++$i) {
672
            if (!isset($levelData[$i])) {
673
                $levelData[$i] = 0;
674
            }
675
        }
676
        // sort array again
677
        ksort($levelData);
678
679
        return $levelData;
680
    }
681
682
    public function getActivePokemon($trainer_name)
683
    {
@@ 712-733 (lines=22) @@
709
        return $pokemon;
710
    }
711
712
    public function getTrainerLevelCount($team_id)
713
    {
714
        $exclue = '';
715
        if (!empty(self::$config->system->trainer_blacklist)) {
716
            $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
717
        }
718
        $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL AND team = '".$team_id."' ".$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level';
719
        $result = pg_query($this->db, $req);
720
        $levelData = array();
721
        while ($data = pg_fetch_object($result)) {
722
            $levelData[$data->level] = $data->count;
723
        }
724
        for ($i = 5; $i <= 40; ++$i) {
725
            if (!isset($levelData[$i])) {
726
                $levelData[$i] = 0;
727
            }
728
        }
729
        // sort array again
730
        ksort($levelData);
731
732
        return $levelData;
733
    }
734
735
    /////////
736
    // Cron