Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
[Updated] Add page to explore all changes of gyms over time #331
Updated version of PR #283
Since I was always curious of what is happening in the gyms in my town, but no historical data is tracked by RocketMap, I have added a new SQL table that does so.
Motivation and Context
Now you are able to see, when gyms are leveled up or down and which Pokémon are placed in or thrown out.
How Has This Been Tested?
Tested in my own Worldopole online instance.
It is necessary to execute some SQL statements that I have documented in readme.gymhistory.md to create the new table and the update events.
Remark: it does not include any localization so far -> english only
Screenshots (if appropriate):
Types of changes
Sttug left a comment •
for some reason y need do this.
DELIMITER // CREATE EVENT IF NOT EXISTS gymhistory_insert ON SCHEDULE EVERY 30 SECOND DO BEGIN INSERT INTO gymhistory (SELECT NULL, g.gym_id, g.team_id, g.guard_pokemon_id, g.total_cp, g.last_modified, g.last_modified as last_updated, (SELECT GROUP_CONCAT(DISTINCT pokemon_uid ORDER BY deployment_time SEPARATOR ',') FROM gymmember AS gm WHERE gm.gym_id = g.gym_id GROUP BY gym_id) AS pokemon_uids, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = g.gym_id) AS pokemon_count FROM gym AS g WHERE g.last_modified > (SELECT MAX(last_modified) FROM gymhistory)); END // DELIMITER ;
CREATE EVENT IF NOT EXISTS gymhistory_update ON SCHEDULE EVERY 30 SECOND DO UPDATE gymhistory AS gh JOIN (SELECT gym_id, MAX(last_modified) as max_last_modified FROM gymhistory GROUP BY gym_id) AS gg ON gh.gym_id = gg.gym_id AND gh.last_modified = gg.max_last_modified JOIN (SELECT gym_id, last_scanned, GROUP_CONCAT(DISTINCT pokemon_uid ORDER BY deployment_time SEPARATOR ',') AS pokemon_uids, COUNT(DISTINCT pokemon_uid) as pokemon_count FROM gymmember AS gm GROUP BY gym_id) AS gm ON gh.gym_id = gm.gym_id SET gh.last_updated = gm.last_scanned, gh.pokemon_uids = gm.pokemon_uids, gh.pokemon_count = gm.pokemon_count WHERE gh.last_updated < gm.last_scanned; END // DELIMITER ;
now work fine (mysql 5.7)
@michikrug Everything seems to be working fine except for the URL and redirects.
When I load