| @@ 141-146 (lines=6) @@ | ||
| 138 | // Single Pokemon |
|
| 139 | /////////////////// |
|
| 140 | ||
| 141 | function getGymsProtectedByPokemon($pokemon_id) { |
|
| 142 | $req = "SELECT COUNT(DISTINCT(fort_id)) AS total FROM fort_sightings WHERE guard_pokemon_id = '".$pokemon_id."'"; |
|
| 143 | $result = $this->mysqli->query($req); |
|
| 144 | $data = $result->fetch_object(); |
|
| 145 | return $data; |
|
| 146 | } |
|
| 147 | ||
| 148 | function getPokemonLastSeen($pokemon_id) { |
|
| 149 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
|
| @@ 148-157 (lines=10) @@ | ||
| 145 | return $data; |
|
| 146 | } |
|
| 147 | ||
| 148 | function getPokemonLastSeen($pokemon_id) { |
|
| 149 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
|
| 150 | FROM sightings |
|
| 151 | WHERE pokemon_id = '".$pokemon_id."' |
|
| 152 | ORDER BY expire_timestamp DESC |
|
| 153 | LIMIT 0,1"; |
|
| 154 | $result = $this->mysqli->query($req); |
|
| 155 | $data = $result->fetch_object(); |
|
| 156 | return $data; |
|
| 157 | } |
|
| 158 | ||
| 159 | function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
|
| 160 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude, |
|
| @@ 430-437 (lines=8) @@ | ||
| 427 | return $counts; |
|
| 428 | } |
|
| 429 | ||
| 430 | public function getPokemonSinceLastUpdate($pokemon_id, $last_update) { |
|
| 431 | $req = "SELECT COUNT(*) AS count, MAX(expire_timestamp) AS last_timestamp, (FROM_UNIXTIME(MAX(expire_timestamp))) AS disappear_time_real, lat as latitude, lon as longitude |
|
| 432 | FROM sightings |
|
| 433 | WHERE pokemon_id = '".$pokemon_id."' && expire_timestamp > '".$last_update."'"; |
|
| 434 | $result = $this->mysqli->query($req); |
|
| 435 | $data = $result->fetch_object(); |
|
| 436 | return $data; |
|
| 437 | } |
|
| 438 | ||
| 439 | public function getRaidsSinceLastUpdate($pokemon_id, $last_update) { |
|
| 440 | $where = "WHERE pokemon_id = '".$pokemon_id."' && time_battle > '".$last_update."'"; |
|
| @@ 142-147 (lines=6) @@ | ||
| 139 | // Single Pokemon |
|
| 140 | /////////////////// |
|
| 141 | ||
| 142 | function getGymsProtectedByPokemon($pokemon_id) { |
|
| 143 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'"; |
|
| 144 | $result = $this->mysqli->query($req); |
|
| 145 | $data = $result->fetch_object(); |
|
| 146 | return $data; |
|
| 147 | } |
|
| 148 | ||
| 149 | function getPokemonLastSeen($pokemon_id) { |
|
| 150 | $req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude |
|
| @@ 149-158 (lines=10) @@ | ||
| 146 | return $data; |
|
| 147 | } |
|
| 148 | ||
| 149 | function getPokemonLastSeen($pokemon_id) { |
|
| 150 | $req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude |
|
| 151 | FROM pokemon |
|
| 152 | WHERE pokemon_id = '".$pokemon_id."' |
|
| 153 | ORDER BY disappear_time DESC |
|
| 154 | LIMIT 0,1"; |
|
| 155 | $result = $this->mysqli->query($req); |
|
| 156 | $data = $result->fetch_object(); |
|
| 157 | return $data; |
|
| 158 | } |
|
| 159 | ||
| 160 | function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
|
| 161 | $req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
|
| @@ 331-340 (lines=10) @@ | ||
| 328 | return $gyms; |
|
| 329 | } |
|
| 330 | ||
| 331 | public function getGymData($gym_id) { |
|
| 332 | $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 333 | (CONVERT_TZ(gym.last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, gym.total_cp AS total_cp, (6 - gym.slots_available) AS level |
|
| 334 | FROM gymdetails |
|
| 335 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
|
| 336 | WHERE gym.gym_id='".$gym_id."'"; |
|
| 337 | $result = $this->mysqli->query($req); |
|
| 338 | $data = $result->fetch_object(); |
|
| 339 | return $data; |
|
| 340 | } |
|
| 341 | ||
| 342 | public function getGymDefenders($gym_id) { |
|
| 343 | $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| @@ 537-544 (lines=8) @@ | ||
| 534 | return $counts; |
|
| 535 | } |
|
| 536 | ||
| 537 | public function getPokemonSinceLastUpdate($pokemon_id, $last_update) { |
|
| 538 | $req = "SELECT COUNT(*) as count, UNIX_TIMESTAMP(MAX(disappear_time)) as last_timestamp, (CONVERT_TZ(MAX(disappear_time), '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude |
|
| 539 | FROM pokemon |
|
| 540 | WHERE pokemon_id = '".$pokemon_id."' && UNIX_TIMESTAMP(disappear_time) > '".$last_update."'"; |
|
| 541 | $result = $this->mysqli->query($req); |
|
| 542 | $data = $result->fetch_object(); |
|
| 543 | return $data; |
|
| 544 | } |
|
| 545 | ||
| 546 | public function getRaidsSinceLastUpdate($pokemon_id, $last_update) { |
|
| 547 | $where = "WHERE pokemon_id = '".$pokemon_id."' && UNIX_TIMESTAMP(start) > '".$last_update."'"; |
|