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

Commit 130045a

Browse files
committed
Add config for KEEP_GYM_HISTORY
1 parent 67e2279 commit 130045a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

config/default.php

+1
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,4 @@
238238
//-----------------------------------------------------
239239

240240
$fork = "default"; // default/asner/sloppy
241+
$alternateKeepGymHistory = false; // alternate - KEEP_GYM_HISTORY is on

config/example.config.php

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228

229229
$map = "monocle"; // monocle/rm
230230
$fork = "default"; // default/asner/sloppy/alternate
231+
$alternateKeepGymHistory = false; // alternate - KEEP_GYM_HISTORY is on
231232

232233
$db = new Medoo([// required
233234
'database_type' => 'mysql', // mysql/mariadb/pgsql/sybase/oracle/mssql/sqlite

lib/Monocle_Alternate.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function get_gyms($swLat, $swLng, $neLat, $neLng, $tstamp = 0, $oSwLat =
214214

215215
public function query_gyms($conds, $params)
216216
{
217-
global $db;
217+
global $db, $alternateKeepGymHistory;
218218

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

243+
if ($alternateKeepGymHistory) {
244+
$query = str_replace(":fort_condition", "fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)", $query);
245+
} else {
246+
$query = str_replace(":fort_condition", "1=1", $query);
247+
}
243248
$query = str_replace(":time", time(), $query);
244249
$query = str_replace(":conditions", join(" AND ", $conds), $query);
245250
$gyms = $db->query($query, $params)->fetchAll(\PDO::FETCH_ASSOC);

0 commit comments

Comments
 (0)