Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pokestops #149

Open
wants to merge 4 commits into
base: forts
Choose a base branch
from
Open

Added Pokestops #149

wants to merge 4 commits into from

Conversation

skarlath
Copy link

@skarlath skarlath commented Aug 8, 2016

Following the logic for Gyms, now scans for pokestops and reports lured
pokemon.

Following the logic for Gyms, now scans for pokestops and reports lured
pokemon.
@SapitoSucio
Copy link

Is there any way to apply your PR from windows using TortoiseGit?

The 'L' does not imply Integer....

Fixed an issue with the adding of lure pokemon

Fixed the timestamp on the lure pokemon

Adjusted the map queries to be more agnostic of the sql engine (tested
on mssql)
@skarlath
Copy link
Author

skarlath commented Aug 9, 2016

I'm not very skilled in git... so i don't know enough to say one way or another, but i would imagine so? I might be able to do a push request to your fork if you'd like...

@SapitoSucio
Copy link

I got it working using a .patch file, but thank you for your offering :)
Now that I am studying the code, it does not detects when a Pokestop is lured to show it as lured in the map, right ?

fixes an issue on db engines that respect constraints
@skarlath
Copy link
Author

skarlath commented Aug 9, 2016

I think that should be fixed now. It is currently updating lure info with the pokemon as long as a worker can see it.

@modrzew
Copy link
Owner

modrzew commented Aug 9, 2016

I appreciate the PR, thanks. But most probably I won't be merging it, as I see no purpose in gathering data about pokestops. I felt the same way about gyms until someone convinced me that it may be purposeful to do it and analyze/display Gyms data over time. There are a lot of variables there: ownership, guarding Pokemon, prestige... which means you can do lot of things with the data. But pokestops? You can only check whether they have lure module and what spawned there, and that seems boring.

I'll leave the PR open in case anyone wants to use it.

@mugabemkomo
Copy link

I would really love to see lured pokestops on the map, makes it a lot easier when you plan your trip to walk around town.

@skarlath
Copy link
Author

skarlath commented Aug 9, 2016

I'm planning to analyze the lure hot spots around my area... We have two distinct zones that are always lured and they seem to have a theme of pokemon, and lately have been dropping rare stuff at certain hours. I will continue to update the PR for others.

@mugabemkomo
Copy link

Thanks alot, I would love to help, but I'm only a network admin and have literally no idea of python :) I'm just glad I can run a community site for a lot of users here because of you guys.

Last_Modified does not update when the lure expires, changed the query
to account for that.

Changed the report queries to work with MSSQL (Hopefully i'm using
pretty standard sql, but might break on other engines...)
@SapitoSucio
Copy link

I'm also planning to analyze the lured pokestops, in my town there aren't many pokestops, and usually there is like 1 or 2 pokestops lured, with the gathered data I could easily know which is the most lured one

@mugabemkomo
Copy link

Hi I was trying to check out your pull request locally, I got a conflict in db.py where i removed the old def get_forts(session)
But when I run web.py and connect to the site I get a lot of exceptions, ending with:

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1582, "Incorrect parameter count in the call to native function 'datediff'") [SQL: "\n SELECT\n ss.stop_id,\n ss.id,\n ss.lure_expires_timestamp_ms,\n ss.encounter_id,\n ss.active_pokemon_id,\n ss.last_modified,\n s.lat,\n s.lon\n FROM stop_sightings ss\n\t\t\tinner join (SELECT max(id) as maxid, stop_id, max(lure_expires_timestamp_ms) as ltime, max(sighting_time) stime from stop_sightings\n\t\t\twhere dateadd(mi, datediff(mi, getutcdate(), getDate()), dateadd(S, lure_expires_timestamp_ms, '1970-01-01')) > getdate() or lure_expires_timestamp_ms = 0\ngroup by stop_id) mss on ss.id = mss.maxid\n JOIN stops s ON s.id=ss.stop_id\n ORDER BY ss.last_modified DESC\n "]

I'm using mysql and it works with normal with the master branch.

@SapitoSucio
Copy link

You need to recreate your sqlfile

import db
db.Base.metadata.create_all(db.get_engine())

@mugabemkomo
Copy link

I tried, I even dropped the whole database and created new tables with import db, but still the same error :(

http://pastebin.com/EihXT5VZ

@skarlath
Copy link
Author

looks like datediff is different between mssql and mysql... mssql takes 3 parameters where as the mysql function takes 2... you'll have to modify the code for mysql...

@mugabemkomo
Copy link

Well thanks, but I guess I have to live without pokestops then I dont want to install a windows machine for that. Unless you take donations for implementing mysql :)

@skarlath
Copy link
Author

SELECT
ss.stop_id,
ss.id,
ss.lure_expires_timestamp_ms,
ss.encounter_id,
ss.active_pokemon_id,
ss.last_modified,
s.lat,
s.lon
FROM stop_sightings ss
inner join (SELECT max(id) as maxid, stop_id, max(lure_expires_timestamp_ms) as ltime, max(sighting_time) stime from stop_sightings
where lure_expires_timestamp_ms > CURRENT_TIMESTAMP or lure_expires_timestamp_ms = 0
group by stop_id) mss on ss.id = mss.maxid
JOIN stops s ON s.id=ss.stop_id
ORDER BY ss.last_modified DESC

I think will work, i don't have mysql to test but the funcitonality should be good

This replaces the query in db.py get_stops

@iluretar
Copy link

For MySQL you have to use UNIX_TIMESTAMP() instead of CURRENT_TIMESTAMP because the latter gives you a formated string and the query never returns lured stops

@iluretar
Copy link

@skarlath this is only showing the stop as lured for the short period of time when such lure spawned a pokemon and a worker was near it, so it only appears lured for 1-2mins. Is this the intended behavior or am i missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants