Comments (7)
This exposes a different problem. The search to include descriptions searches for inclusiveness, not an exact match. Another example of this bug being relevant is pokemon #304, Aron (which will provide descriptions for volcarana as well.)
I'm not a python guy, so I'm a little slow in finding the pain point, but I'll submit a PR if I catch it.
from pokeapi.
@TheIronDeveloper this is exactly what is causing the issue. It's looking for values with the name of the pokémon in, so Abra will get Kadabra's name because: Kadabra.
It needs some regex magic work instead of a simple icontains
from pokeapi.
Line 46 in pokemon/api.py is where that pain point is. I could fix it if I actually knew what was doing what. (My knowledge of django is spotty)
The build_descriptions function passes "name" which is what icontains is looking for within the Description.objects.filter QuerySet. My only problem is not knowing what that QuerySet actually is.
For instance, if that QuerySet is "kadabra_gen_4", the easiest fix would just be to compare length with something like
if (len(str(Description.object.filter))-6) == len(name):
ds = Description.objects.filter(name__icontains=name)
lst = []
........
And so on. This would cause it so that only Pokemon with names the same length of as what you're looking for (subtracting 6 for the generation tag). Making Abra (4) and Kadabra (7) unable to be matched, while comparing Abra to Aron and Uxie. I figure this will work, but I have no actual means of testing it, since I have no idea what icontains is looking in and I can't get the API working outside of the stuff in dev_data.json.
from pokeapi.
This is a good starting point for the filtering: https://docs.djangoproject.com/en/1.8/ref/models/querysets/#id4
And the regex in particular: https://docs.djangoproject.com/en/1.8/ref/models/querysets/#regex
Django knowledge isn't important here, string interpolation is what will solve this. Can you write a regular expression that matches on strings correctly? The name string is always something like this:
"abra_gen_1"
"abra_gen_6"
"kadabra_gen_1"
"kadabra_gen_4"
from pokeapi.
So here's a super simple fix to the build_descriptions function. It still uses icontains, but before appending the list, it checks to see if the name matches using the same method I described above, checking to see if the name of the Pokemon it's adding to the list is the same length as the name of the Pokemon it's looking for.
Let me know if this works, and if not I'll try something else.
from pokeapi.
I'll need to look into the syntax of icontains, but I'd have to imagine you can do a regex like:
'/^' + name + '/'
from pokeapi.
Okay, this is the last thing I will be fixing on V1, all other features requests for V1 are being deprecated and closed.
from pokeapi.
Related Issues (20)
- Data Model doesnt consider the subcategories of Pokemon HOT 2
- Differences in different APIs handling forms HOT 3
- Provide PMD Portraits and Sprites HOT 4
- Change API to have only one Pokemon endpoint, instead of pokemon_species, pokemon_forms and pokemon HOT 17
- Dual normal-types displaying normal-type as ability HOT 1
- GraphQL api is down HOT 3
- Add pokemon cries to GraphqQL response HOT 1
- move effect prose 1 and 104 are the same HOT 3
- Why isnt csv a submodule just like sprites and cries? HOT 2
- Pokemons rename in species request HOT 2
- Problem with item flag countable HOT 4
- Link up --physical and --special Z moves to complete their data HOT 1
- Eevee's gender differences HOT 5
- Feature Request: Show if a pokemon in Nintendo Switch games can be transfered from Pokemon Home HOT 1
- Brambleghast missing Egg moves HOT 3
- Burmy cloaks
- Egg Cycles HOT 4
- Maximum and Minimum of Stats HOT 2
- SyntaxError: JSON.parse HOT 4
- Missing documentation for unnamed API resources HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pokeapi.