Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Add config for KEEP_GYM_HISTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
j16sdiz committed Feb 27, 2018
1 parent 67e2279 commit 130045a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,4 @@
//-----------------------------------------------------

$fork = "default"; // default/asner/sloppy
$alternateKeepGymHistory = false; // alternate - KEEP_GYM_HISTORY is on
1 change: 1 addition & 0 deletions config/example.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@

$map = "monocle"; // monocle/rm
$fork = "default"; // default/asner/sloppy/alternate
$alternateKeepGymHistory = false; // alternate - KEEP_GYM_HISTORY is on

$db = new Medoo([// required
'database_type' => 'mysql', // mysql/mariadb/pgsql/sybase/oracle/mssql/sqlite
Expand Down
9 changes: 7 additions & 2 deletions lib/Monocle_Alternate.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function get_gyms($swLat, $swLng, $neLat, $neLng, $tstamp = 0, $oSwLat =

public function query_gyms($conds, $params)
{
global $db;
global $db, $alternateKeepGymHistory;

$query = "SELECT
f.external_id AS gym_id,
Expand All @@ -236,10 +236,15 @@ public function query_gyms($conds, $params)
r.move_1 AS raid_pokemon_move_1,
r.move_2 AS raid_pokemon_move_2
FROM forts f
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))
LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND :fort_condition)
LEFT JOIN raids r ON (r.fort_id = f.id AND r.time_end >= :time)
WHERE :conditions";

if ($alternateKeepGymHistory) {
$query = str_replace(":fort_condition", "fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)", $query);
} else {
$query = str_replace(":fort_condition", "1=1", $query);
}
$query = str_replace(":time", time(), $query);
$query = str_replace(":conditions", join(" AND ", $conds), $query);
$gyms = $db->query($query, $params)->fetchAll(\PDO::FETCH_ASSOC);
Expand Down

0 comments on commit 130045a

Please sign in to comment.