|
@@ 629-650 (lines=22) @@
|
| 626 |
|
return $trainers; |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
public function getTrainerLevelRanking() |
| 630 |
|
{ |
| 631 |
|
$exclue = ''; |
| 632 |
|
if (!empty(self::$config->system->trainer_blacklist)) { |
| 633 |
|
$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
| 634 |
|
} |
| 635 |
|
$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'; |
| 636 |
|
$result = pg_query($this->db, $req); |
| 637 |
|
$levelData = array(); |
| 638 |
|
while ($data = pg_fetch_object($result)) { |
| 639 |
|
$levelData[$data->level] = $data->count; |
| 640 |
|
} |
| 641 |
|
for ($i = 5; $i <= 40; ++$i) { |
| 642 |
|
if (!isset($levelData[$i])) { |
| 643 |
|
$levelData[$i] = 0; |
| 644 |
|
} |
| 645 |
|
} |
| 646 |
|
// sort array again |
| 647 |
|
ksort($levelData); |
| 648 |
|
|
| 649 |
|
return $levelData; |
| 650 |
|
} |
| 651 |
|
|
| 652 |
|
public function getActivePokemon($trainer_name) |
| 653 |
|
{ |
|
@@ 682-703 (lines=22) @@
|
| 679 |
|
return $pokemon; |
| 680 |
|
} |
| 681 |
|
|
| 682 |
|
public function getTrainerLevelCount($team_id) |
| 683 |
|
{ |
| 684 |
|
$exclue = ''; |
| 685 |
|
if (!empty(self::$config->system->trainer_blacklist)) { |
| 686 |
|
$exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
| 687 |
|
} |
| 688 |
|
$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'; |
| 689 |
|
$result = pg_query($this->db, $req); |
| 690 |
|
$levelData = array(); |
| 691 |
|
while ($data = pg_fetch_object($result)) { |
| 692 |
|
$levelData[$data->level] = $data->count; |
| 693 |
|
} |
| 694 |
|
for ($i = 5; $i <= 40; ++$i) { |
| 695 |
|
if (!isset($levelData[$i])) { |
| 696 |
|
$levelData[$i] = 0; |
| 697 |
|
} |
| 698 |
|
} |
| 699 |
|
// sort array again |
| 700 |
|
ksort($levelData); |
| 701 |
|
|
| 702 |
|
return $levelData; |
| 703 |
|
} |
| 704 |
|
|
| 705 |
|
///////// |
| 706 |
|
// Cron |