@@ 658-679 (lines=22) @@ | ||
655 | return $trainers; |
|
656 | } |
|
657 | ||
658 | public function getTrainerLevelRanking() |
|
659 | { |
|
660 | $exclue = ''; |
|
661 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
662 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
663 | } |
|
664 | $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'; |
|
665 | $result = $this->mysqli->query($req); |
|
666 | $levelData = array(); |
|
667 | while ($data = $result->fetch_object()) { |
|
668 | $levelData[$data->level] = $data->count; |
|
669 | } |
|
670 | for ($i = 5; $i <= 40; ++$i) { |
|
671 | if (!isset($levelData[$i])) { |
|
672 | $levelData[$i] = 0; |
|
673 | } |
|
674 | } |
|
675 | // sort array again |
|
676 | ksort($levelData); |
|
677 | ||
678 | return $levelData; |
|
679 | } |
|
680 | ||
681 | public function getActivePokemon($trainer_name) |
|
682 | { |
|
@@ 711-732 (lines=22) @@ | ||
708 | return $pokemon; |
|
709 | } |
|
710 | ||
711 | public function getTrainerLevelCount($team_id) |
|
712 | { |
|
713 | $exclue = ''; |
|
714 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
715 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
716 | } |
|
717 | $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'; |
|
718 | $result = $this->mysqli->query($req); |
|
719 | $levelData = array(); |
|
720 | while ($data = $result->fetch_object()) { |
|
721 | $levelData[$data->level] = $data->count; |
|
722 | } |
|
723 | for ($i = 5; $i <= 40; ++$i) { |
|
724 | if (!isset($levelData[$i])) { |
|
725 | $levelData[$i] = 0; |
|
726 | } |
|
727 | } |
|
728 | // sort array again |
|
729 | ksort($levelData); |
|
730 | ||
731 | return $levelData; |
|
732 | } |
|
733 | ||
734 | ///////// |
|
735 | // Cron |
@@ 644-665 (lines=22) @@ | ||
641 | return $trainers; |
|
642 | } |
|
643 | ||
644 | public function getTrainerLevelCount($team_id) |
|
645 | { |
|
646 | $req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'"; |
|
647 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
648 | $req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
649 | } |
|
650 | $req .= ' GROUP BY level'; |
|
651 | $result = $this->mysqli->query($req); |
|
652 | $levelData = array(); |
|
653 | while ($data = $result->fetch_object()) { |
|
654 | $levelData[$data->level] = $data->count; |
|
655 | } |
|
656 | for ($i = 5; $i <= 40; ++$i) { |
|
657 | if (!isset($levelData[$i])) { |
|
658 | $levelData[$i] = 0; |
|
659 | } |
|
660 | } |
|
661 | // sort array again |
|
662 | ksort($levelData); |
|
663 | ||
664 | return $levelData; |
|
665 | } |
|
666 | ||
667 | private function getTrainerData($trainer_name, $team, $page, $ranking) |
|
668 | { |