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 past Pokemon type data #457

Merged
merged 18 commits into from
Feb 12, 2021
Merged

Conversation

phrasmotica
Copy link
Contributor

@phrasmotica phrasmotica commented Nov 30, 2019

These changes add data describing a Pokemon's types in a previous generation. All Pokemon that have different type(s) to when they were first introduced are included, and are as follows:

  • Cleffa/Clefairy/Clefable: Normal until gen VI
  • Igglybuff/Jigglypuff/Wigglytuff: Normal until gen VI
  • Magnemite/Magneton: Electric until gen II
  • Mime Jr./Mr. Mime: Psychic until gen VI
  • Togepi: Normal until gen VI
  • Togetic/Togekiss: Normal/Flying until Gen VI
  • Marill/Azumarill: Normal until gen VI
  • Snubbull/Granbull: Normal until gen VI
  • Ralts/Kirlia/Gardevoir: Psychic until gen VI
  • Azurill: Normal until gen VI
  • Mawile: Steel until gen VI
  • Cottonee/Whimsicott: Grass until gen VI
  • Rotom-Heat/Wash/Frost/Fan/Mow: Electric-Ghost until gen V

The new CSV file has entries containing the Pokemon's ID, the last generation in which they had the listed type, the type and its slot.

A Pokemon resource now has a past_types JSON field:

"past_types": [
    {
        "generation": {
            "name": "generation-v",
            "url": "https://pokeapi.co/api/v2/generation/5/"
        },
        "types": [
            {
                "slot": 1,
                "type": {
                    "name": "grass",
                    "url": "https://pokeapi.co/api/v2/type/12/"
                }
            }
        ]
    }
]

The API README file has been updated with an explanation of the new data and example JSON from Clefairy.

Data derived from https://bulbapedia.bulbagarden.net/wiki/Category:Pok%C3%A9mon_that_have_had_their_type_changed.

@Naramsim
Copy link
Member

Naramsim commented Dec 1, 2019

Whoa, @phrasmotica thanks for the amazing work! But maybe it was better to open an issue before doing all of this.

Right now we fetch our data from Veekun so we are using directly their files, without touching them. We don't really want to fix or add files by ourselves.

Maybe you can open an issue at Veekun (https://github.com/veekun/pokedex) and check what do they think about adding a pokemon_types_past.csv file.

I'm not saying that we don't like your contribution but I can say that we will hardly merge it if Veekun doesn't integrate it.

Will you please open an issue at Veekun and link this one here over there?

Thanks again!!

@phrasmotica
Copy link
Contributor Author

phrasmotica commented Dec 1, 2019

@Naramsim thanks for the kind words! I did rush into making the changes and opening this PR without asking what the process is... this is some data I'd like to use in a project of mine, after all!

I'll open an issue in Veekun's Pokedex and link it to this one 😄

  • open issue in Veekun's Pokedex (here)
  • get some feedback

@phrasmotica
Copy link
Contributor Author

phrasmotica commented Feb 6, 2021

Hey! I've just come back to this project and seen that a break's being taken from using Veekun's data. Any chance I can revive this issue and add the data directly? I'm in the process of merging master back into my branch.

While I'm at it, I think I might make the types field into a list of objects containing the generation and the appropriate types, and absorb the past_types field into it. Thoughts? actually this might be catastrophic for existing libraries. I take it back 😄

@phrasmotica
Copy link
Contributor Author

Aha, I see that there is a fork of Veekun's pokedex repo in this project. Should the stuff in this PR be merged there instead?

@Naramsim
Copy link
Member

Naramsim commented Feb 8, 2021

Hi @phrasmotica,

thanks for sticking with us :) You can just keep this PR open. I'll need to review it again as I don't remember its contents. But basically, you've added a new CSV file that keeps track of changes to the types of pokemon, right?

@phrasmotica
Copy link
Contributor Author

@Naramsim exactly! My original comment describing the change is still accurate. And thank you for revisiting this :)

@Naramsim
Copy link
Member

Alright, I looked at the diff and built it. Whenever I try to query the local API I get a 500.

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 279, in handle
    keepalive = self.handle_request(req, conn)
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 328, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 142, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 78, in get_response
    response = self._middleware_chain(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 128, in handle_uncaught_exception
    callback, param_dict = resolver.resolve_error_handler(500)
  File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 546, in resolve_error_handler
    callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
  File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/code/config/urls.py", line 2, in <module>
    from pokemon_v2 import urls as pokemon_v2_urls
  File "/code/pokemon_v2/urls.py", line 10, in <module>
    from pokemon_v2.api import *
  File "/code/pokemon_v2/api.py", line 9, in <module>
    from .serializers import *
  File "/code/pokemon_v2/serializers.py", line 389, in <module>
    class PokemonTypePastSerializer(serializers.ModelSerializer):
  File "/code/pokemon_v2/serializers.py", line 394, in PokemonTypePastSerializer
    class Meta:
  File "/code/pokemon_v2/serializers.py", line 395, in Meta
    model = PokemonTypePast
NameError: name 'PokemonTypePast' is not defined

Does it also happen to you? The build works fine.

@phrasmotica
Copy link
Contributor Author

@Naramsim after checking out the branch fresh, running make install, make setup and populating the DB, I've tried it with numerous Pokemon endpoints (/pokemon/1/, /pokemon/35/, /pokemon/36/ and /pokemon/122/) and get a 200 each time.

@Naramsim
Copy link
Member

Nice, I did it. I had to remove the docker volume. So the Django flush doesn't really work well here, when there are schema modifications. I have to dig a bit deeper and find a suitable command to properly clean the DB.

So @phrasmotica, everything works very well! Thanks for the contribution and also for writing the tests!

I'm merging. Also, we need to integrate the changes you made to our .md files over at our PokeAPI/pokeapi.co repo. I don't know if you like to help there as well.

@Naramsim Naramsim self-requested a review February 12, 2021 20:47
@Naramsim Naramsim merged commit e2e43d8 into PokeAPI:master Feb 12, 2021
@pokeapi-machine-user
Copy link

A PokeAPI/api-data refresh has started. In 45 minutes the staging branch of PokeAPI/api-data will be pushed with the new generated data.

The staging branch will be deployed in our staging environment and you will be able to review the entire API.

A Pull Request (master<-staging) will be also created at PokeAPI/api-data and assigned to the PokeAPI Core team to be reviewed. If approved and merged new data will soon be available worldwide at pokeapi.co.

@pokeapi-machine-user
Copy link

The updater script has finished its job and has now opened a Pull Request towards PokeAPI/api-data with the updated data.

You can see the Pull Request deployed at our staging environment when CircleCI deploy will be finished (check the started time of the last build).

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.

3 participants