|
@@ 171-185 (lines=15) @@
|
| 168 |
|
return $data; |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
| 172 |
|
$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, |
| 173 |
|
cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
| 174 |
|
ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form |
| 175 |
|
FROM sightings |
| 176 |
|
WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0' |
| 177 |
|
ORDER BY $top_order_by $top_direction, expire_timestamp DESC |
| 178 |
|
LIMIT 50 OFFSET 0"; |
| 179 |
|
$result = pg_query($this->db, $req); |
| 180 |
|
$top = array(); |
| 181 |
|
while ($data = pg_fetch_object($result)) { |
| 182 |
|
$top[] = $data; |
| 183 |
|
} |
| 184 |
|
return $top; |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
| 188 |
|
$trainer_blacklist = ""; |
|
@@ 488-502 (lines=15) @@
|
| 485 |
|
// Raids |
| 486 |
|
/////////// |
| 487 |
|
|
| 488 |
|
public function getAllRaids($page) { |
| 489 |
|
$limit = " LIMIT 10 OFFSET ". ($page * 10); |
| 490 |
|
$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 |
| 491 |
|
FROM forts f |
| 492 |
|
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)) |
| 493 |
|
LEFT JOIN raids r ON (r.fort_id = f.id AND r.time_end >= UNIX_TIMESTAMP()) |
| 494 |
|
WHERE r.time_end > EXTRACT(EPOCH FROM NOW()) |
| 495 |
|
ORDER BY r.level DESC, r.time_battle" . $limit; |
| 496 |
|
$result = pg_query($this->db, $req); |
| 497 |
|
$raids = array(); |
| 498 |
|
while ($data = pg_fetch_object($result)) { |
| 499 |
|
$raids[] = $data; |
| 500 |
|
} |
| 501 |
|
return $raids; |
| 502 |
|
} |
| 503 |
|
|
| 504 |
|
|
| 505 |
|
////////////// |