|
@@ 79-84 (lines=6) @@
|
| 76 |
|
// Homepage |
| 77 |
|
///////////// |
| 78 |
|
|
| 79 |
|
public function getTotalPokemon() |
| 80 |
|
{ |
| 81 |
|
$req = 'SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW())'; |
| 82 |
|
$result = pg_query($this->db, $req); |
| 83 |
|
$data = pg_fetch_object($result); |
| 84 |
|
|
| 85 |
|
return $data; |
| 86 |
|
} |
| 87 |
|
|
|
@@ 95-100 (lines=6) @@
|
| 92 |
|
return $data; |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
public function getTotalGyms() |
| 96 |
|
{ |
| 97 |
|
$req = 'SELECT COUNT(*) AS total FROM forts'; |
| 98 |
|
$result = pg_query($this->db, $req); |
| 99 |
|
$data = pg_fetch_object($result); |
| 100 |
|
|
| 101 |
|
return $data; |
| 102 |
|
} |
| 103 |
|
|
|
@@ 104-109 (lines=6) @@
|
| 101 |
|
return $data; |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
public function getTotalRaids() |
| 105 |
|
{ |
| 106 |
|
$req = 'SELECT COUNT(*) AS total FROM raids WHERE time_battle <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())'; |
| 107 |
|
$result = pg_query($this->db, $req); |
| 108 |
|
$data = pg_fetch_object($result); |
| 109 |
|
|
| 110 |
|
return $data; |
| 111 |
|
} |
| 112 |
|
|
|
@@ 113-121 (lines=9) @@
|
| 110 |
|
return $data; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
public function getTotalGymsForTeam($team_id) |
| 114 |
|
{ |
| 115 |
|
$req = "SELECT COUNT(*) AS total |
| 116 |
|
FROM forts f |
| 117 |
|
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)) |
| 118 |
|
WHERE team = '$team_id'"; |
| 119 |
|
$result = pg_query($this->db, $req); |
| 120 |
|
$data = pg_fetch_object($result); |
| 121 |
|
|
| 122 |
|
return $data; |
| 123 |
|
} |
| 124 |
|
|
|
@@ 166-174 (lines=9) @@
|
| 163 |
|
// Single Pokemon |
| 164 |
|
/////////////////// |
| 165 |
|
|
| 166 |
|
public function getGymsProtectedByPokemon($pokemon_id) |
| 167 |
|
{ |
| 168 |
|
$req = "SELECT COUNT(f.id) AS total |
| 169 |
|
FROM forts f |
| 170 |
|
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)) |
| 171 |
|
WHERE guard_pokemon_id = '".$pokemon_id."'"; |
| 172 |
|
$result = pg_query($this->db, $req); |
| 173 |
|
$data = pg_fetch_object($result); |
| 174 |
|
|
| 175 |
|
return $data; |
| 176 |
|
} |
| 177 |
|
|
|
@@ 178-187 (lines=10) @@
|
| 175 |
|
return $data; |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
public function getPokemonLastSeen($pokemon_id) |
| 179 |
|
{ |
| 180 |
|
$req = "SELECT TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
| 181 |
|
FROM sightings |
| 182 |
|
WHERE pokemon_id = '".$pokemon_id."' |
| 183 |
|
ORDER BY expire_timestamp DESC |
| 184 |
|
LIMIT 1 OFFSET 0"; |
| 185 |
|
$result = pg_query($this->db, $req); |
| 186 |
|
$data = pg_fetch_object($result); |
| 187 |
|
|
| 188 |
|
return $data; |
| 189 |
|
} |
| 190 |
|
|
|
@@ 301-306 (lines=6) @@
|
| 298 |
|
return $spawns; |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
public function getPokemonSliderMinMax() |
| 302 |
|
{ |
| 303 |
|
$req = 'SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings'; |
| 304 |
|
$result = pg_query($this->db, $req); |
| 305 |
|
$data = pg_fetch_object($result); |
| 306 |
|
|
| 307 |
|
return $data; |
| 308 |
|
} |
| 309 |
|
|
|
@@ 310-315 (lines=6) @@
|
| 307 |
|
return $data; |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
public function getMapsCoords() |
| 311 |
|
{ |
| 312 |
|
$req = 'SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints'; |
| 313 |
|
$result = pg_query($this->db, $req); |
| 314 |
|
$data = pg_fetch_object($result); |
| 315 |
|
|
| 316 |
|
return $data; |
| 317 |
|
} |
| 318 |
|
|
|
@@ 319-326 (lines=8) @@
|
| 316 |
|
return $data; |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
public function getPokemonCount($pokemon_id) |
| 320 |
|
{ |
| 321 |
|
$req = 'SELECT count, last_seen, latitude, longitude |
| 322 |
|
FROM pokemon_stats |
| 323 |
|
WHERE pid = '.$pokemon_id; |
| 324 |
|
$result = pg_query($this->db, $req); |
| 325 |
|
$data = pg_fetch_object($result); |
| 326 |
|
|
| 327 |
|
return $data; |
| 328 |
|
} |
| 329 |
|
|
|
@@ 330-337 (lines=8) @@
|
| 327 |
|
return $data; |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
public function getRaidCount($pokemon_id) |
| 331 |
|
{ |
| 332 |
|
$req = 'SELECT count, last_seen, latitude, longitude |
| 333 |
|
FROM raid_stats |
| 334 |
|
WHERE pid = '.$pokemon_id; |
| 335 |
|
$result = pg_query($this->db, $req); |
| 336 |
|
$data = pg_fetch_object($result); |
| 337 |
|
|
| 338 |
|
return $data; |
| 339 |
|
} |
| 340 |
|
|
|
@@ 345-350 (lines=6) @@
|
| 342 |
|
// Pokestops |
| 343 |
|
////////////// |
| 344 |
|
|
| 345 |
|
public function getTotalPokestops() |
| 346 |
|
{ |
| 347 |
|
$req = 'SELECT COUNT(*) as total FROM pokestops'; |
| 348 |
|
$result = pg_query($this->db, $req); |
| 349 |
|
$data = pg_fetch_object($result); |
| 350 |
|
|
| 351 |
|
return $data; |
| 352 |
|
} |
| 353 |
|
|
|
@@ 386-394 (lines=9) @@
|
| 383 |
|
return $datas; |
| 384 |
|
} |
| 385 |
|
|
| 386 |
|
public function getOwnedAndPoints($team_id) |
| 387 |
|
{ |
| 388 |
|
$req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points |
| 389 |
|
FROM forts f |
| 390 |
|
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)) |
| 391 |
|
WHERE fs.team = '".$team_id."'"; |
| 392 |
|
$result = pg_query($this->db, $req); |
| 393 |
|
$data = pg_fetch_object($result); |
| 394 |
|
|
| 395 |
|
return $data; |
| 396 |
|
} |
| 397 |
|
|
|
@@ 412-421 (lines=10) @@
|
| 409 |
|
return $gyms; |
| 410 |
|
} |
| 411 |
|
|
| 412 |
|
public function getGymData($gym_id) |
| 413 |
|
{ |
| 414 |
|
$req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, TO_TIMESTAMP(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp |
| 415 |
|
FROM forts f |
| 416 |
|
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)) |
| 417 |
|
WHERE f.id ='".$gym_id."' |
| 418 |
|
GROUP BY f.name, f.url, fs.team, fs.updated, fs.guard_pokemon_id, fs.slots_available, gd.cp"; |
| 419 |
|
$result = pg_query($this->db, $req); |
| 420 |
|
$data = pg_fetch_object($result); |
| 421 |
|
|
| 422 |
|
return $data; |
| 423 |
|
} |
| 424 |
|
|
|
@@ 739-744 (lines=6) @@
|
| 736 |
|
return $counts; |
| 737 |
|
} |
| 738 |
|
|
| 739 |
|
public function getCaptchaCount() |
| 740 |
|
{ |
| 741 |
|
$req = ' SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL'; |
| 742 |
|
$result = pg_query($this->db, $req); |
| 743 |
|
$data = pg_fetch_object($result); |
| 744 |
|
|
| 745 |
|
return $data; |
| 746 |
|
} |
| 747 |
|
|