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

Add CP and Level to db, webhook, and frontend #277

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

tallypokemap
Copy link

CP and Pokemon Level are as useful as IV in that if you level 30 accounts they are nice to report. Since we are reporting IV, it makes sense to report CP and Level as well. Credit to Asner who's code helped me add CP.

.gitmodules Outdated
@@ -1,4 +1,4 @@
[submodule "monocle-icons"]
path = monocle/static/monocle-icons
url = https://github.com/Noctem/monocle-icons.git
url = https://github.com/Imaginum/monocle-icons.git
Copy link

@walaoaaa1234 walaoaaa1234 Jun 3, 2017

Choose a reason for hiding this comment

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

change back to original repo
monocle/static/monocle-icons << remove?

Copy link
Author

Choose a reason for hiding this comment

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

Duh.... good catch.

@nickmhc
Copy link

nickmhc commented Jun 4, 2017

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 411, in _query
    rowcount = self._do_query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 374, in _do_query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 292, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1054, "Unknown column 'mystery_sightings.cp' in 'field list'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/nmc/github/monocle/monocle/db_proc.py", line 46, in run
    db.add_mystery(session, item)
  File "/home/nmc/github/monocle/monocle/db.py", line 441, in add_mystery
    .filter(Mystery.spawn_id == pokemon['spawn_id']) \
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/query.py", line 2755, in first
    ret = list(self[0:1])
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/query.py", line 2547, in __getitem__
    return list(res)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
    return self._execute_and_instances(context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 411, in _query
    rowcount = self._do_query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/cursors.py", line 374, in _do_query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/MySQLdb/connections.py", line 292, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1054, "Unknown column 'mystery_sightings.cp' in 'field list'") [SQL: 'SELECT mystery_sightings.id AS mystery_sightings_id, mystery_sightings.pokemon_id AS mystery_sightings_pokemon_id, mystery_sightings.spawn_id AS mystery_sightings_spawn_id, mystery_sightings.encounter_id AS mystery_sightings_encounter_id, mystery_sightings.lat AS mystery_sightings_lat, mystery_sightings.lon AS mystery_sightings_lon, mystery_sightings.first_seen AS mystery_sightings_first_seen, mystery_sightings.first_seconds AS mystery_sightings_first_seconds, mystery_sightings.last_seconds AS mystery_sightings_last_seconds, mystery_sightings.seen_range AS mystery_sightings_seen_range, mystery_sightings.atk_iv AS mystery_sightings_atk_iv, mystery_sightings.def_iv AS mystery_sightings_def_iv, mystery_sightings.sta_iv AS mystery_sightings_sta_iv, mystery_sightings.move_1 AS mystery_sightings_move_1, mystery_sightings.move_2 AS mystery_sightings_move_2, mystery_sightings.cp AS mystery_sightings_cp, mystery_sightings.cp_multiplier AS mystery_sightings_cp_multiplier \nFROM mystery_sightings \nWHERE mystery_sightings.encounter_id = %s AND mystery_sightings.spawn_id = %s \n LIMIT %s'] [parameters: (11998290704452769133, 8848365737923, 1)]```

@walaoaaa1234
Copy link

mysql migration, add this 2 column manually to mystery_sightings, sightings @nickmhc

 +    cp = Column(SmallInteger)
 +    cp_multiplier = Column(FLOAT_TYPE)

@tejas0029
Copy link

I need someone to use the map and make a report bot with showing cp iv and moveset
I am paying for it
Need it for discord
Message if anyone can do it

} else {
content += 'IV: ' + item.atk + ' atk, ' + item.def + ' def, ' + item.sta + ' sta<br>';
content += 'CP: ' + item.cp + ' | Lvl: ' + item.level + '<br>';
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please replace the tabs with spaces

@@ -105,6 +105,9 @@ def sighting_to_marker(pokemon, names=POKEMON, moves=MOVES, damage=DAMAGE):
marker['move2'] = moves[move2]
marker['damage1'] = damage[move1]
marker['damage2'] = damage[move2]
if pokemon.cp:
Copy link
Contributor

Choose a reason for hiding this comment

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

it you add the cp column it should be filled with null or 0, so I'd guess this is not needed as it would only be a "if there still are legacy pokemon" which should disapear after 30-60 mins

web_sanic.py Outdated
@@ -177,6 +177,9 @@ def sighting_to_marker(pokemon, names=POKEMON, moves=MOVES, damage=DAMAGE, trash
marker['move2'] = moves[move2]
marker['damage1'] = damage[move1]
marker['damage2'] = damage[move2]
if pokemon.cp:
marker['cp'] = pokemon.cp
Copy link

Choose a reason for hiding this comment

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

Also, this should be "pokemon['cp'] and pokemon['cp_multiplier']
Make sure you are importing your calc_pokemon_level func as well

@tejas0029
Copy link

Hello i am looking for a developer to prepare discord coordinate bot.
You seem experienced and well known, i pay for work
Reply if interested

@tejas0029
Copy link

Hello i am looking for a developer to prepare discord coordinate bot.
You seem experienced and well known, i pay for work
Reply if interested
Mail--- rajm74506@gmail.com

@jesshub
Copy link

jesshub commented Jun 11, 2017

Can this be approved?
Thanks

Copy link

@imp3tus imp3tus left a comment

Choose a reason for hiding this comment

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

extra space at Line 794 of worker.py

@Bart274
Copy link

Bart274 commented Jun 15, 2017

@tallypokemap it would be awesome if you could also include height and weight and form for unowns into the db so it could be shown on the map and in the webhook. this is helpful for getting the Fisherman and Youngster badges :-)

} else {
content += 'IV: ' + item.atk + ' atk, ' + item.def + ' def, ' + item.sta + ' sta<br>';
content += 'CP: ' + item.cp + ' | Lvl: ' + item.level + '<br>';
} else {
Copy link
Contributor

@evenly-epic-mule evenly-epic-mule Jun 15, 2017

Choose a reason for hiding this comment

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

indentation

monocle/db.py Outdated
) test
group by spawn_id
''')
return query
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please create a own branch for this PR or not merge other stuff until it is closed?

monocle/db.py Outdated
@@ -225,6 +225,8 @@ class Sighting(Base):
sta_iv = Column(TINY_TYPE)
move_1 = Column(SmallInteger)
move_2 = Column(SmallInteger)
cp = Column(SmallInteger)
cp_multiplier = Column(FLOAT_TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to save the level here.
That way cp_multiplier => level is computed once, otherwise you are doing it once for every visitor (in web.py / web_sanic.py) besides an extra one for the webhook.
besides that a SmallInteger should use less space than a FLOAT_TYPE

@evenly-epic-mule
Copy link
Contributor

@Bart274 that shouldn't be done as a column each, as it only needs more resources - I think we need a extra_details column or so besides that it should go in an own PR

@evenly-epic-mule
Copy link
Contributor

@tallypokemap besides the requested changes it would be nice if you'd merge the commits together

@tallypokemap tallypokemap force-pushed the develop branch 3 times, most recently from 931a6ab to 2981baf Compare June 16, 2017 21:53
Copy link
Contributor

@evenly-epic-mule evenly-epic-mule left a comment

Choose a reason for hiding this comment

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

just as a little hint git commit --amend will let you update your last commit
but you will then have to push with git push -f

@@ -5,7 +5,7 @@

from monocle import sanitized as conf
from monocle.db import get_forts, Pokestop, session_scope, Sighting, Spawnpoint
from monocle.utils import Units, get_address
from monocle.utils import Units, get_address, calc_pokemon_level
Copy link
Contributor

Choose a reason for hiding this comment

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

that shouldn't be needed anylonger

@tallypokemap
Copy link
Author

For those updating from a previous version:
mysql migration, delete this column from mystery_sightings, sightings

  • cp_multiplier = Column(FLOAT_TYPE)

and replace with

  • level = Column(SmallInteger)

@tallypokemap tallypokemap force-pushed the develop branch 5 times, most recently from 298d122 to a0779ba Compare June 27, 2017 13:11
@just2codes
Copy link

How far is this to be merged ? Just tried it and aint working

@tallypokemap tallypokemap force-pushed the develop branch 2 times, most recently from 9253892 to c2e5193 Compare July 8, 2017 15:23
@nickmhc
Copy link

nickmhc commented Jul 11, 2017

I just tried this and it doesn't work for level information anymore

@M3G4THEKING
Copy link

Workers, but dont display the correct cp and level of pokemons @tallypokemap

@tallypokemap
Copy link
Author

@nickmhc You might need to check your logs to see what is going on. I still have level working just fine on my map.
@m3g4mInD You will need Level 30 workers for it to show the correct stats for a level 30 player. Everything below level 30 is randomized.

@M3G4THEKING
Copy link

M3G4THEKING commented Jul 14, 2017

@tallypokemap yeap i use all accts lv 30+, but still have this issue.i have verifie all accts, all accts detect larvitar and snorlax, they dont are sb or warnings
Update: Now all works fine,thanks

@tallypokemap tallypokemap force-pushed the develop branch 2 times, most recently from 59f2524 to a550a64 Compare July 24, 2017 20:35
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.

10 participants