| @@ 396-429 (lines=34) @@ | ||
| 393 | // Gym History |
|
| 394 | //////////////// |
|
| 395 | ||
| 396 | public function getGymHistories($gym_name, $team, $page, $ranking) |
|
| 397 | { |
|
| 398 | $where = ''; |
|
| 399 | if (isset($gym_name) && $gym_name != '') { |
|
| 400 | $where = " WHERE name LIKE '%".$gym_name."%'"; |
|
| 401 | } |
|
| 402 | if (isset($team) && $team != '') { |
|
| 403 | $where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team; |
|
| 404 | } |
|
| 405 | switch ($ranking) { |
|
| 406 | case 1: |
|
| 407 | $order = " ORDER BY name, last_modified DESC"; |
|
| 408 | break; |
|
| 409 | case 2: |
|
| 410 | $order = " ORDER BY total_cp DESC, last_modified DESC"; |
|
| 411 | break; |
|
| 412 | default: |
|
| 413 | $order = " ORDER BY last_modified DESC, name"; |
|
| 414 | } |
|
| 415 | ||
| 416 | $limit = " LIMIT ".($page * 10).",10"; |
|
| 417 | ||
| 418 | $req = "SELECT f.id as gym_id, fs.total_cp, f.name, fs.team as team_id, (6 - slots_available) as pokemon_count, FROM_UNIXTIME(last_modified) AS last_modified |
|
| 419 | FROM forts f |
|
| 420 | 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)) |
|
| 421 | ".$where.$order.$limit; |
|
| 422 | ||
| 423 | $result = $this->mysqli->query($req); |
|
| 424 | $gym_history = array(); |
|
| 425 | while ($data = $result->fetch_object()) { |
|
| 426 | $gym_history[] = $data; |
|
| 427 | } |
|
| 428 | return $gym_history; |
|
| 429 | } |
|
| 430 | ||
| 431 | public function getGymHistoriesPokemon($gym_id) |
|
| 432 | { |
|
| @@ 360-393 (lines=34) @@ | ||
| 357 | // Gym History |
|
| 358 | //////////////// |
|
| 359 | ||
| 360 | public function getGymHistories($gym_name, $team, $page, $ranking) { |
|
| 361 | $where = ''; |
|
| 362 | if (isset($gym_name) && $gym_name != '') { |
|
| 363 | $where = " WHERE name LIKE '%".$gym_name."%'"; |
|
| 364 | } |
|
| 365 | if (isset($team) && $team != '') { |
|
| 366 | $where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team; |
|
| 367 | } |
|
| 368 | switch ($ranking) { |
|
| 369 | case 1: |
|
| 370 | $order = " ORDER BY name, last_modified DESC"; |
|
| 371 | break; |
|
| 372 | case 2: |
|
| 373 | $order = " ORDER BY total_cp DESC, last_modified DESC"; |
|
| 374 | break; |
|
| 375 | default: |
|
| 376 | $order = " ORDER BY last_modified DESC, name"; |
|
| 377 | } |
|
| 378 | ||
| 379 | $limit = " LIMIT ".($page * 10).",10"; |
|
| 380 | ||
| 381 | $req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '" . self::$time_offset . "')) as last_modified |
|
| 382 | FROM gymdetails |
|
| 383 | LEFT JOIN gym |
|
| 384 | ON gymdetails.gym_id = gym.gym_id |
|
| 385 | ".$where.$order.$limit; |
|
| 386 | ||
| 387 | $result = $this->mysqli->query($req); |
|
| 388 | $gym_history = array(); |
|
| 389 | while ($data = $result->fetch_object()) { |
|
| 390 | $gym_history[] = $data; |
|
| 391 | } |
|
| 392 | return $gym_history; |
|
| 393 | } |
|
| 394 | ||
| 395 | public function getGymHistoriesPokemon($gym_id) { |
|
| 396 | $req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name |
|
| @@ 381-414 (lines=34) @@ | ||
| 378 | // Gym History |
|
| 379 | //////////////// |
|
| 380 | ||
| 381 | public function getGymHistories($gym_name, $team, $page, $ranking) |
|
| 382 | { |
|
| 383 | $where = ''; |
|
| 384 | if (isset($gym_name) && $gym_name != '') { |
|
| 385 | $where = " WHERE name LIKE '%".$gym_name."%'"; |
|
| 386 | } |
|
| 387 | if (isset($team) && $team != '') { |
|
| 388 | $where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team; |
|
| 389 | } |
|
| 390 | switch ($ranking) { |
|
| 391 | case 1: |
|
| 392 | $order = " ORDER BY name, last_modified DESC"; |
|
| 393 | break; |
|
| 394 | case 2: |
|
| 395 | $order = " ORDER BY total_cp DESC, last_modified DESC"; |
|
| 396 | break; |
|
| 397 | default: |
|
| 398 | $order = " ORDER BY last_modified DESC, name"; |
|
| 399 | } |
|
| 400 | ||
| 401 | $limit = " LIMIT 10 OFFSET ".($page * 10); |
|
| 402 | ||
| 403 | $req = "SELECT f.id as gym_id, fs.total_cp, f.name, fs.team as team_id, (6 - slots_available) as pokemon_count, TO_TIMESTAMP(last_modified) AS last_modified |
|
| 404 | FROM forts f |
|
| 405 | 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)) |
|
| 406 | ".$where.$order.$limit; |
|
| 407 | ||
| 408 | $result = $this->mysqli->query($req); |
|
| 409 | $gym_history = array(); |
|
| 410 | while ($data = $result->fetch_object()) { |
|
| 411 | $gym_history[] = $data; |
|
| 412 | } |
|
| 413 | return $gym_history; |
|
| 414 | } |
|
| 415 | ||
| 416 | public function getGymHistoriesPokemon($gym_id) |
|
| 417 | { |
|