@@ 191-205 (lines=15) @@ | ||
188 | return $data; |
|
189 | } |
|
190 | ||
191 | public function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) |
|
192 | { |
|
193 | $req = "SELECT expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude, |
|
194 | cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
|
195 | ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form |
|
196 | FROM sightings |
|
197 | WHERE pokemon_id = '".$pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
198 | ORDER BY $top_order_by $top_direction, expire_timestamp DESC |
|
199 | LIMIT 50 OFFSET 0"; |
|
200 | $result = pg_query($this->db, $req); |
|
201 | $top = array(); |
|
202 | while ($data = pg_fetch_object($result)) { |
|
203 | $top[] = $data; |
|
204 | } |
|
205 | ||
206 | return $top; |
|
207 | } |
|
208 | ||
@@ 563-576 (lines=14) @@ | ||
560 | return array('last_page' => $last_page, 'data' => $history); |
|
561 | } |
|
562 | ||
563 | private function getHistoryForGymPokemon($gym_id, $last_modified) |
|
564 | { |
|
565 | $req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name |
|
566 | FROM gym_history_defenders ghd |
|
567 | JOIN gym_defenders gd ON ghd.defender_id = gd.external_id |
|
568 | WHERE ghd.fort_id = '".$gym_id."' AND date = '".$last_modified."' |
|
569 | ORDER BY gd.deployment_time"; |
|
570 | $result = pg_query($this->db, $req); |
|
571 | $pokemons = array(); |
|
572 | while ($data = pg_fetch_object($result)) { |
|
573 | $pokemons[$data->defender_id] = $data; |
|
574 | } |
|
575 | ||
576 | return $pokemons; |
|
577 | } |
|
578 | ||
579 | /////////// |
|
@@ 583-597 (lines=15) @@ | ||
580 | // Raids |
|
581 | /////////// |
|
582 | ||
583 | public function getAllRaids($page) |
|
584 | { |
|
585 | $limit = ' LIMIT 10 OFFSET '.($page * 10); |
|
586 | $req = 'SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude |
|
587 | FROM forts f |
|
588 | 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)) |
|
589 | LEFT JOIN raids r ON (r.fort_id = f.id AND r.time_end >= UNIX_TIMESTAMP()) |
|
590 | WHERE r.time_end > EXTRACT(EPOCH FROM NOW()) |
|
591 | ORDER BY r.level DESC, r.time_battle'.$limit; |
|
592 | $result = pg_query($this->db, $req); |
|
593 | $raids = array(); |
|
594 | while ($data = pg_fetch_object($result)) { |
|
595 | $raids[] = $data; |
|
596 | } |
|
597 | ||
598 | return $raids; |
|
599 | } |
|
600 |