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

Raids [BACKEND ONLY] #306

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open

Raids [BACKEND ONLY] #306

wants to merge 56 commits into from

Conversation

sebast1219
Copy link

@sebast1219 sebast1219 commented Jun 26, 2017

Raid infos are implemented, feel free to add this fuctionnality on the frontend (I'm just using a personnal discord bot)

Table fort_raids
Fields :

  • id = Column(Integer, primary_key=True)
  • fort_id = Column(Integer, ForeignKey('forts.id'))
  • raid_seed = Column(Integer)
  • raid_battle_ms = Column(Integer, index=True)
  • raid_spawn_ms = Column(Integer, index=True)
  • raid_end_ms = Column(Integer, index=True)
  • raid_level = Column(Integer)
  • complete = Column(TINY_TYPE)
  • pokemon_id = Column(TINY_TYPE)
  • cp = Column(TINY_TYPE)
  • move_1 = Column(SmallInteger)
  • move_2 = Column(SmallInteger)

pokemon_id,cp,move_1 and move_2 are updated when raid battle starts

Noctem and others added 30 commits April 28, 2017 01:01
0.4 has not been released yet so use the latest commit from the develop
branch instead.
Use asynchronous spawn cache in pogeo.monotools.
Remove dependence on shapely and geopy, improve performance of
landmarks, automate landmark pickling/unpickling, read landmarks from
config as a sequence of dicts instead of a Landmarks object, a little
refactoring, miscellaneous fixes.
Add an example script for converting old-style landmarks configurations
(constructing an actual Landmarks instance in config.py) with the
new-style of using standard Python data-types (a tuple/list of dicts).
Use correct cache in add_mystery, use visit_point instead of visit in
Overseer, fix setting spawn/despawn times in update_spawns, fix some
variable names in Worker.
monocle/db.py Outdated
pokemon_id = Column(TINY_TYPE)
cp = Column(TINY_TYPE)
move_1 = Column(SmallInteger)
move_2 = Column(SmallInteger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the moves matter at all? as everyone will get something else after catching it

Copy link

@thordurk91 thordurk91 Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moves are the same for everyone in the battle against the raid boss. Thus it is a strategy part knowing if he has certain moves

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you sure? what i heard is not same when in battle and after caught

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't use it but that could be usefull to counter him

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walaoaaa1234 the moveset is the same for the raid boss battle but afterwards we get a randomized moveset for the capturable version.

monocle/db.py Outdated
raid_level = Column(Integer)
complete = Column(TINY_TYPE)
pokemon_id = Column(TINY_TYPE)
cp = Column(TINY_TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the CP not the same for the same pokemon?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the CP of the boss ;) Not everytime the same imo

fort_raid['pokemon_id'] = fort.raid_info.raid_pokemon.pokemon_id
fort_raid['cp'] = fort.raid_info.raid_pokemon.cp
fort_raid['move_1'] = fort.raid_info.raid_pokemon.move_1
fort_raid['move_2'] = fort.raid_info.raid_pokemon.move_2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines (after if fort.HasField('raid_info'):) should be part of normalize_raid

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already does...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the code should be moved to the normalize_raid method
only leaving {} here

if fort.HasField('raid_info') and fort not in RAID_CACHE:
    db_proc.add(self.normalize_raid(fort_raid))

@@ -27,7 +27,7 @@
from monocle.utils import get_address, dump_pickle
from monocle.worker import Worker
from monocle.overseer import Overseer
from monocle.db import FORT_CACHE
from monocle.db import FORT_CACHE,RAID_CACHE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a space in between :)

fort_raid['pokemon_id'] = fort.raid_info.raid_pokemon.pokemon_id
fort_raid['cp'] = fort.raid_info.raid_pokemon.cp
fort_raid['move_1'] = fort.raid_info.raid_pokemon.move_1
fort_raid['move_2'] = fort.raid_info.raid_pokemon.move_2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the code should be moved to the normalize_raid method
only leaving {} here

if fort.HasField('raid_info') and fort not in RAID_CACHE:
    db_proc.add(self.normalize_raid(fort_raid))

fort_raid['pokemon_id'] = ""
fort_raid['cp'] = ""
fort_raid['move_1'] = ""
fort_raid['move_2'] = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be set to 0 as they are being saved as integer

@j16sdiz
Copy link
Contributor

j16sdiz commented Jun 26, 2017

Can you do a rebase with whitespace / newline fix?
It is very difficult to review as is.

@sebast1219
Copy link
Author

Everything should be stable now. Tell me if you still have some troubles

@NiliusJulius
Copy link

I'm not sure why it happens, but when I run locally on my windows pc, it works fine.
However when I run this on my ubuntu server it doesn't write to the mysql database. when I stop scan.py it has a huge backlog of items it still wants to push to the DB.
It works fine without this addition however.

So it looks like it isn't able to write the data to the fort_raids table (because that stays empty) and that is clogging upp the writing to the DB.

@sebast1219
Copy link
Author

Can you drop fort_raid table, rerun create_db and retest it plz? (Don't forget to pull the lastest version of the PR)

@NiliusJulius
Copy link

Removing everything and reinstalling it all seems to have worked. However, the update function seems to be clogging it all up now.
On a fresh database everything works fine. but as soon as it tries to update an entry to include the raid boss, it blocks up the DB again.

monocle/db.py Outdated
cp = '{cp}',
move_1 = '{move_1}',
move_2 = '{move_2}',
notifDiscord = NULL

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifDiscord has to be removed in order for the update function to work.

@sebast1219
Copy link
Author

Corrected notifDiscord ;)
Sorry for that

monocle/db.py Outdated
raid_spawn_ms = Column(Integer, index=True)
raid_end_ms = Column(Integer, index=True)
raid_level = Column(Integer)
complete = Column(TINY_TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be boolean for postgresql

__tablename__ = 'fort_raids'
id = Column(Integer, primary_key=True)
fort_id = Column(Integer, ForeignKey('forts.id'))
raid_seed = Column(String(50))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postgresql complain this

psycopg2.ProgrammingError: operator does not exist: character varying = bigint                     
LINE 3: WHERE fort_raids.raid_seed =  -6036655490970226155 AND fort_...            

monocle/db.py Outdated
cp = '{cp}',
move_1 = '{move_1}',
move_2 = '{move_2}',
notifDiscord = NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifdiscord not exist in the table defination

@baskettcase
Copy link

I just want to make sure that this will work with SPAWN_ID_INT = false ?

@baskettcase
Copy link

baskettcase commented Jun 27, 2017

Ok Im testing this out and Im getting a bunch of MySQL errors when the raid hasn't started yet since move_1, move_2, etc can not be "None" since they are smallint according to your specs, so the only thing that can be saved at this point are actual raid battles, not raid eggs.

Update 1: Ok I set it so that those fields could be NULL and that fixed that problem. My raid seed is a negative number.. is that correct?

@sebast1219
Copy link
Author

Yep the raid_seed is a negative number for what i saw

@baskettcase
Copy link

baskettcase commented Jun 29, 2017

@sebast1219 Im unsure if I have the proper MySQL column types, do you have a create table that I can compare to? Also as I've been running this it doesn't seem like the raids are updated. I get when the initial raid is going to start, so all the moves, etc are NULL, but they never update to the actual raid info when it starts. I have a bunch of NULL in the database and only a very few that actually have the raid info after it has started, but I have a feeling that it was the first time it put those raids in the database and the raid was going when that happened.. so basically it doesn't seem to be updating the raid info. Also is there a way to keep track of when a raid is going to start and then deploy an account to get the raid info, just like a spawnpoint TTL?

@baskettcase
Copy link

@sebast1219 I know I asked on the gym one, but maybe a combo of gym and raid webhook? So when a gym changes teams and also when a raid is announced and starts?

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

Successfully merging this pull request may close these issues.

8 participants