| @@ 166-171 (lines=6) @@ | ||
| 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 = $this->mysqli->query($req); |
|
| 173 | $data = $result->fetch_object(); |
|
| 174 | ||
| @@ 178-187 (lines=10) @@ | ||
| 175 | return $data; |
|
| 176 | } |
|
| 177 | ||
| 178 | public function getPokemonLastSeen($pokemon_id) |
|
| 179 | { |
|
| 180 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(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 0,1"; |
|
| 185 | $result = $this->mysqli->query($req); |
|
| 186 | $data = $result->fetch_object(); |
|
| 187 | ||
| 188 | return $data; |
|
| 189 | } |
|
| 190 | ||
| @@ 320-329 (lines=10) @@ | ||
| 317 | return $data; |
|
| 318 | } |
|
| 319 | ||
| 320 | public function getPokemonCount($pokemon_id) |
|
| 321 | { |
|
| 322 | $req = 'SELECT count, last_seen, latitude, longitude |
|
| 323 | FROM pokemon_stats |
|
| 324 | WHERE pid = '.$pokemon_id; |
|
| 325 | $result = $this->mysqli->query($req); |
|
| 326 | $data = $result->fetch_object(); |
|
| 327 | ||
| 328 | return $data; |
|
| 329 | } |
|
| 330 | ||
| 331 | public function getPokemonCountAll() |
|
| 332 | { |
|
| @@ 345-354 (lines=10) @@ | ||
| 342 | return $array; |
|
| 343 | } |
|
| 344 | ||
| 345 | public function getRaidCount($pokemon_id) |
|
| 346 | { |
|
| 347 | $req = 'SELECT count, last_seen, latitude, longitude |
|
| 348 | FROM raid_stats |
|
| 349 | WHERE pid = '.$pokemon_id; |
|
| 350 | $result = $this->mysqli->query($req); |
|
| 351 | $data = $result->fetch_object(); |
|
| 352 | ||
| 353 | return $data; |
|
| 354 | } |
|
| 355 | ||
| 356 | public function getRaidCountAll() |
|
| 357 | { |
|
| @@ 415-425 (lines=11) @@ | ||
| 412 | return $datas; |
|
| 413 | } |
|
| 414 | ||
| 415 | public function getOwnedAndPoints($team_id) |
|
| 416 | { |
|
| 417 | $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points |
|
| 418 | FROM forts f |
|
| 419 | 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)) |
|
| 420 | WHERE fs.team = '".$team_id."'"; |
|
| 421 | $result = $this->mysqli->query($req); |
|
| 422 | $data = $result->fetch_object(); |
|
| 423 | ||
| 424 | return $data; |
|
| 425 | } |
|
| 426 | ||
| 427 | public function getAllGyms() |
|
| 428 | { |
|
| @@ 441-451 (lines=11) @@ | ||
| 438 | return $gyms; |
|
| 439 | } |
|
| 440 | ||
| 441 | public function getGymData($gym_id) |
|
| 442 | { |
|
| 443 | $req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, FROM_UNIXTIME(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp |
|
| 444 | FROM forts f |
|
| 445 | 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)) |
|
| 446 | WHERE f.id ='".$gym_id."'"; |
|
| 447 | $result = $this->mysqli->query($req); |
|
| 448 | $data = $result->fetch_object(); |
|
| 449 | ||
| 450 | return $data; |
|
| 451 | } |
|
| 452 | ||
| 453 | public function getGymDefenders($gym_id) |
|
| 454 | { |
|
| @@ 167-172 (lines=6) @@ | ||
| 164 | // Single Pokemon |
|
| 165 | /////////////////// |
|
| 166 | ||
| 167 | public function getGymsProtectedByPokemon($pokemon_id) |
|
| 168 | { |
|
| 169 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'"; |
|
| 170 | $result = $this->mysqli->query($req); |
|
| 171 | $data = $result->fetch_object(); |
|
| 172 | ||
| 173 | return $data; |
|
| 174 | } |
|
| 175 | ||
| @@ 176-185 (lines=10) @@ | ||
| 173 | return $data; |
|
| 174 | } |
|
| 175 | ||
| 176 | public function getPokemonLastSeen($pokemon_id) |
|
| 177 | { |
|
| 178 | $req = "SELECT disappear_time, |
|
| 179 | CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."') AS disappear_time_real, |
|
| 180 | latitude, longitude |
|
| 181 | FROM pokemon |
|
| 182 | WHERE pokemon_id = '".$pokemon_id."' |
|
| 183 | ORDER BY disappear_time DESC |
|
| 184 | LIMIT 0,1"; |
|
| 185 | $result = $this->mysqli->query($req); |
|
| 186 | $data = $result->fetch_object(); |
|
| 187 | ||
| 188 | return $data; |
|
| @@ 115-122 (lines=8) @@ | ||
| 112 | return $data; |
|
| 113 | } |
|
| 114 | ||
| 115 | public function getTotalGymsForTeam($team_id) |
|
| 116 | { |
|
| 117 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'"; |
|
| 118 | $result = $this->mysqli->query($req); |
|
| 119 | $data = $result->fetch_object(); |
|
| 120 | ||
| 121 | return $data; |
|
| 122 | } |
|
| 123 | ||
| 124 | public function getRecentAll() |
|
| 125 | { |
|
| @@ 322-331 (lines=10) @@ | ||
| 319 | return $data; |
|
| 320 | } |
|
| 321 | ||
| 322 | public function getPokemonCount($pokemon_id) |
|
| 323 | { |
|
| 324 | $req = 'SELECT count, last_seen, latitude, longitude |
|
| 325 | FROM pokemon_stats |
|
| 326 | WHERE pid = '.$pokemon_id; |
|
| 327 | $result = $this->mysqli->query($req); |
|
| 328 | $data = $result->fetch_object(); |
|
| 329 | ||
| 330 | return $data; |
|
| 331 | } |
|
| 332 | ||
| 333 | public function getPokemonCountAll() |
|
| 334 | { |
|
| @@ 347-356 (lines=10) @@ | ||
| 344 | return $array; |
|
| 345 | } |
|
| 346 | ||
| 347 | public function getRaidCount($pokemon_id) |
|
| 348 | { |
|
| 349 | $req = 'SELECT count, last_seen, latitude, longitude |
|
| 350 | FROM raid_stats |
|
| 351 | WHERE pid = '.$pokemon_id; |
|
| 352 | $result = $this->mysqli->query($req); |
|
| 353 | $data = $result->fetch_object(); |
|
| 354 | ||
| 355 | return $data; |
|
| 356 | } |
|
| 357 | ||
| 358 | public function getRaidCountAll() |
|
| 359 | { |
|
| @@ 419-429 (lines=11) @@ | ||
| 416 | return $datas; |
|
| 417 | } |
|
| 418 | ||
| 419 | public function getOwnedAndPoints($team_id) |
|
| 420 | { |
|
| 421 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, |
|
| 422 | ROUND(AVG(total_cp),0) AS average_points |
|
| 423 | FROM gym |
|
| 424 | WHERE team_id = '".$team_id."'"; |
|
| 425 | $result = $this->mysqli->query($req); |
|
| 426 | $data = $result->fetch_object(); |
|
| 427 | ||
| 428 | return $data; |
|
| 429 | } |
|
| 430 | ||
| 431 | public function getAllGyms() |
|
| 432 | { |
|
| @@ 446-455 (lines=10) @@ | ||
| 443 | return $gyms; |
|
| 444 | } |
|
| 445 | ||
| 446 | public function getGymData($gym_id) |
|
| 447 | { |
|
| 448 | $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 449 | CONVERT_TZ(gym.last_scanned, '+00:00', '".self::$time_offset."') AS last_scanned, |
|
| 450 | gym.guard_pokemon_id AS guard_pokemon_id, |
|
| 451 | gym.total_cp AS total_cp, |
|
| 452 | (6 - gym.slots_available) AS level |
|
| 453 | FROM gymdetails |
|
| 454 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
|
| 455 | WHERE gym.gym_id='".$gym_id."'"; |
|
| 456 | $result = $this->mysqli->query($req); |
|
| 457 | $data = $result->fetch_object(); |
|
| 458 | ||
| @@ 115-122 (lines=8) @@ | ||
| 112 | return $data; |
|
| 113 | } |
|
| 114 | ||
| 115 | public function getTotalGymsForTeam($team_id) |
|
| 116 | { |
|
| 117 | $req = 'SELECT COUNT(*) AS total FROM gym WHERE team_id = '.$team_id; |
|
| 118 | $result = $this->mysqli->query($req); |
|
| 119 | $data = $result->fetch_object(); |
|
| 120 | ||
| 121 | return $data; |
|
| 122 | } |
|
| 123 | ||
| 124 | public function getRecentAll() |
|
| 125 | { |
|
| @@ 170-181 (lines=12) @@ | ||
| 167 | return array(); |
|
| 168 | } |
|
| 169 | ||
| 170 | public function getPokemonLastSeen($pokemon_id) |
|
| 171 | { |
|
| 172 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
|
| 173 | FROM pokemon |
|
| 174 | WHERE pokemon_id = '".$pokemon_id."' |
|
| 175 | ORDER BY expire_timestamp DESC |
|
| 176 | LIMIT 0,1"; |
|
| 177 | $result = $this->mysqli->query($req); |
|
| 178 | $data = $result->fetch_object(); |
|
| 179 | ||
| 180 | return $data; |
|
| 181 | } |
|
| 182 | ||
| 183 | public function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) |
|
| 184 | { |
|
| @@ 294-303 (lines=10) @@ | ||
| 291 | return $data; |
|
| 292 | } |
|
| 293 | ||
| 294 | public function getPokemonCount($pokemon_id) |
|
| 295 | { |
|
| 296 | $req = 'SELECT COALESCE(SUM(count),0) as count, MAX(date) as last_seen_day |
|
| 297 | FROM pokemon_stats |
|
| 298 | WHERE pokemon_id = '.$pokemon_id; |
|
| 299 | $result = $this->mysqli->query($req); |
|
| 300 | $data = $result->fetch_object(); |
|
| 301 | ||
| 302 | return $data; |
|
| 303 | } |
|
| 304 | ||
| 305 | public function getPokemonCountAll() |
|
| 306 | { |
|
| @@ 320-329 (lines=10) @@ | ||
| 317 | } |
|
| 318 | ||
| 319 | ||
| 320 | public function getRaidCount($pokemon_id) |
|
| 321 | { |
|
| 322 | $req = 'SELECT COALESCE(SUM(count),0) as count, MAX(date) as last_seen_day |
|
| 323 | FROM raid_stats |
|
| 324 | WHERE pokemon_id = '.$pokemon_id; |
|
| 325 | $result = $this->mysqli->query($req); |
|
| 326 | $data = $result->fetch_object(); |
|
| 327 | ||
| 328 | return $data; |
|
| 329 | } |
|
| 330 | ||
| 331 | public function getRaidCountAll() |
|
| 332 | { |
|
| @@ 379-388 (lines=10) @@ | ||
| 376 | return array(); |
|
| 377 | } |
|
| 378 | ||
| 379 | public function getOwnedAndPoints($team_id) |
|
| 380 | { |
|
| 381 | $req = "SELECT COUNT(id) AS total, ROUND(AVG(total_cp)) AS average_points |
|
| 382 | FROM gym |
|
| 383 | WHERE team_id = '".$team_id."'"; |
|
| 384 | $result = $this->mysqli->query($req); |
|
| 385 | $data = $result->fetch_object(); |
|
| 386 | ||
| 387 | return $data; |
|
| 388 | } |
|
| 389 | ||
| 390 | public function getAllGyms() |
|
| 391 | { |
|
| @@ 403-412 (lines=10) @@ | ||
| 400 | return $gyms; |
|
| 401 | } |
|
| 402 | ||
| 403 | public function getGymData($gym_id) |
|
| 404 | { |
|
| 405 | $req = "SELECT name, null AS description, url, team_id AS team, FROM_UNIXTIME(updated) AS last_scanned, guarding_pokemon_id AS guard_pokemon_id, (6 - availble_slots) AS level, total_cp |
|
| 406 | FROM gym |
|
| 407 | WHERE id = '".$gym_id."'"; |
|
| 408 | $result = $this->mysqli->query($req); |
|
| 409 | $data = $result->fetch_object(); |
|
| 410 | ||
| 411 | return $data; |
|
| 412 | } |
|
| 413 | ||
| 414 | public function getGymDefenders($gym_id) |
|
| 415 | { |
|