Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

[Instant Answer] Pokemon info #1536

Merged
merged 19 commits into from
Mar 20, 2015
Merged

[Instant Answer] Pokemon info #1536

merged 19 commits into from
Mar 20, 2015

Conversation

AkA84
Copy link

@AkA84 AkA84 commented Feb 16, 2015

What does your Instant Answer do?
It provides basic information and stats about a given pokemon

What problem does your Instant Answer solve (Why is it better than organic links)?
At a glance the user gets:

  • A picture of the pokemon
  • A description (randomly selected from the set given by the API)
  • The types and egg groups the pokemon belongs to
  • The name of the pokemon's next evolution (with a link to its IA)
  • The basic stats

I think that's a good amount of information that the user gets before he/she even clicks any of the search results

What is the data source for your Instant Answer? (Provide a link if possible)
http://pokeapi.co/

According to the API author, API V1 should get deprecated this year and replaced by V2 (source). "Deprecated" in this case just means that the V1 will be rendered stable and it won't receive any more updates. I haven't found any information about the new API, but nothing prevents the IA to use V1 for now and then upgrade to V2 once it's out

Why did you choose this data source?
It's a nice, RESTful, widely used API

Are there any other alternative (better) data sources?
I kinda quickly settled on pokeapi since it seemed pretty good, but as far as I can tell I haven't found a decent competitor for it

What are some example queries that trigger this Instant Answer?
pokemon pikachu, bulbasaur pokemon

Which communities will this Instant Answer be especially useful for? (gamers, book lovers, etc)
Pokemon lovers!

Is this Instant Answer connected to a DuckDuckHack Instant Answer idea?
https://duck.co/ideas/idea/4921/pok-mon-info

Which existing Instant Answers will this one supersede/overlap with?
None, as far as I know

Are you having any problems? Do you need our help with anything?

  • I know that there is a built-in record template, but I couldn't figure out how to have it render a non-escaped string, which is necessary to have the link to the pokemon's evolution (i know about Handlebars.SafeString method but it doesn't seem to work as I suspect it's not something that the template expect to receive). I thought it would be cool thing to have since it allows the user to jumps back and forth different pokemon's evolutions, so for now I recreated the record mark-up while waiting to get some feedback from you
  • On mobile the "auxiliary context" box disappears for my IA, but not for others. I noticed that the .cw wrapper is supposed to also get an .has-aux class to prevent it, but I'm not sure how to add that

Where did you hear about DuckDuckHack? (For first time contributors)
It popped up in conversation about privacy issues, and I found it quite interesting. It wasn't though until recently that I found out about your IA, and I'm really fascinated by the concept

What does the Instant Answer look like? (Provide a screenshot for new or updated Instant Answers)
pokemon-ia-example

Checklist

Please place an 'X' where appropriate.

[x] Added metadata and attribution information
[x] Wrote test file and added to t/ directory
[x] Verified that Instant Answer adheres to design guidelines (https://duck.co/duckduckhack/design_styleguide)
[x] Verified that Instant Answer adheres to code styleguide (https://duck.co/duckduckhack/code_styleguide)
[] Tested cross-browser compatibility

    Please let us know which browsers/devices you've tested on:
    - Windows 8
        [] Google Chrome
        [] Firefox
        [] Opera
        [] IE 10

    - Windows 7
        [] Google Chrome
        [] Firefox
        [] Opera
        [] IE 8
        [x] IE 9
        [] IE 10

    - Windows XP
        [] IE 7
        [] IE 8

    - Mac OSX
        [x] Google Chrome
        [x] Firefox
        [] Opera
        [x] Safari

    - iOS (iPhone)
        [] Safari Mobile
        [] Google Chrome
        [] Opera

    - iOS (iPad)
        [x] Safari Mobile
        [x] Google Chrome
        [] Opera

    - Android
        [x] Firefox
        [x] Native Browser
        [x] Google Chrome
        [] Opera

IA Page: https://duck.co/ia/view/pokemon_data

AkA84 added 4 commits February 14, 2015 00:04
* Use the Auxiliary Information Box to display the pokemon's stats
* Don't display an image if the API doesn't return any sprites for the pokemon
* JS refactoring
The IA now displays also a pokemon's description, chosen randomly between a given set.
Since the description is served≈ by the API via a different endpoint (/description/{id})
a Pokemon::Description endpoint has been added
@zekiel
Copy link
Member

zekiel commented Feb 16, 2015

Thanks @AkA84! Can you please fill out the pull request template and drop it in this thread? https://github.com/duckduckgo/duckduckgo-documentation/blob/master/templates/pull_request_template.md

@AkA84
Copy link
Author

AkA84 commented Feb 16, 2015

Sure, will do!

@AkA84
Copy link
Author

AkA84 commented Feb 16, 2015

Ok added, now going through your code styleguide and amending bits here and there of the code to be sure it adheres to it

@AkA84
Copy link
Author

AkA84 commented Feb 16, 2015

Done, I also checked the IA with the browsers and devices that I have available at the moment

@zekiel
Copy link
Member

zekiel commented Feb 16, 2015

many thanks!

@phalt
Copy link

phalt commented Feb 17, 2015

Hi, PokéAPI author here. I'm just commenting to say you've made my day 😂

@phalt
Copy link

phalt commented Feb 17, 2015

@zekiel concerned about extra traffic hitting the servers - do you cache these queries at all? I should be able to handle quite a bit of traffic (already on 30k+ a day)

@moollaza
Copy link
Member

Hey @phalt!

I'm just commenting to say you've made my day

Haha I'm so glad to hear that! I didn't realize you were also responsible for swapi.co which I believe someone else is planning on integrating into an Instant Answer 👍

do you cache these queries at all? I should be able to handle quite a bit of traffic (already on 30k+ a day)

Yes, absolutely! We can cache this for as long as you'd like. Seeing as this stuff is pretty static we can increase the caching as much as you'd like. 1 week? 1 month?

@AkA84 All that needs to be done is to set spice proxy_cache_valid to something like 200 30d. This would cache HTTP 200 responses for 1 months.

More details: https://duck.co/duckduckhack/spice_advanced_backend#caching

@phalt
Copy link

phalt commented Feb 17, 2015

@moollaza Any reasonable caching is fine. As I said - the tough little server I have this running on can take upwards of 30k hits a day with no problems, so scaling it a bit more shouldn't be too hard. If it get bad, who can I email?

@moollaza
Copy link
Member

scaling it a bit more shouldn't be too hard. If it get bad, who can I email?

@phalt sounds good! If you need anything, feel free to email me: [email protected]

@AkA84
Copy link
Author

AkA84 commented Feb 17, 2015

@AkA84 All that needs to be done is to set spice proxy_cache_valid to something like 200 30d. This would cache HTTP 200 responses for 1 months.

Done!

Hi, PokéAPI author here. I'm just commenting to say you've made my day 😂

@phalt I'm really happy to hear that! Since you're here 😄 a couple of things:

  • Just FYI: the Instant Answer will make two calls to the API, one to the pokemon/{name} endpoint and a second one to /description/{id} to get the pokemon's description
  • Speaking about additional calls: I wanted to avoid making a separate call to get the pokemon's sprite (via the /sprite/{id}), so I'm fetching it directly on /media/img/{national_id}.png. Do you see any potential problem with that? So far with all the tests I've made it worked pretty good

@phalt
Copy link

phalt commented Feb 17, 2015

@AkA84

  • Perfectly fine and that's how it is designed - RESTful!
  • No problem doing that at all, it's just a direct link to the image file.

@ghost
Copy link

ghost commented Feb 18, 2015

I am so glad that this is being added to Duckduckgo, but in the example(pokemon pikachu, bulbasaur pokemon) you have to add the word Pokemon. Is there any way that the word Pokemon could be made not mandatory?(all you have to do is search "pikachu" or "buizel")

@AkA84
Copy link
Author

AkA84 commented Feb 19, 2015

@kasarov55555 that is something that aimed at when I started working on the IA, but I wouldn't know how it worked if you didn't provide a static "hook" for the IA to be triggered with.

At the same time I see that there is for example the Definition IA that although it lists a series of triggers, it still shows up if you simply write a word (for example it works with both "awesome definition" and "awesome")

I'd really like the IA to be triggered by queries like "pikachu" or "pikachu stats", but being the first time I develop one I'd need the help from the DDG guys :)

@MrChrisW
Copy link
Collaborator

@AkA84 I've been following this PR and it looks awesome! Great to see the API owner is here too 👍

I'd really like the IA to be triggered by queries like "pikachu" or "pikachu stats", but being the first time I develop one I'd need the help from the DDG guys :)

You could get this IA triggering on just a pokemon name "pikachu" however that would require maintaining a list of all known names and slurping that for use as triggers. An example is the Airlines IA which uses a list of known Airline in a text file

The only issues I see with doing this is the maintainability, e.g if more pokemon are created the list needs updating.

I've also noticed there seems to be an internal IA using the "Pokemon Encyclopedia" as a source which is triggered by name https://duckduckgo.com/?q=Buizel&ia=about
There's also the standard "Wikipedia" IA which triggers as well https://duckduckgo.com/Pikachu?ia=about although these can potentially be changed (I think) if a better option is available 😄

@AkA84
Copy link
Author

AkA84 commented Feb 19, 2015

@AkA84 I've been following this PR and it looks awesome!

@MrChrisW thanks!

You could get this IA triggering on just a pokemon name "pikachu" however that would require maintaining a list of all known names and slurping that for use as triggers.

As you said I don't think it's very maintainable and the list of pokemon is quite long! Also, if you need to manually amend a list, where's the fun in that 😄

I'm still curious about how the Dictionary IA works, because it seems to be triggered even without any static trigger in the query!

I've also noticed there seems to be an internal IA using the "Pokemon Encyclopedia" as a source which is triggered by name https://duckduckgo.com/?q=Buizel&ia=about

Mmm this is not good, I see a bit of overlapping here :-/

@MrChrisW
Copy link
Collaborator

As you said I don't think it's very maintainable and the list of pokemon is quite long! Also, if you need to manually amend a list, where's the fun in that

Exactly! Best to let the API handle the updating 😉

I'm still curious about how the Dictionary IA works, because it seems to be triggered even without any static trigger in the query!

I'm guessing that's due to internal triggers configured by DDG, specificity these triggers may detect if a dictionary link is returned in the SERP and then the Dictionary IA is called. (I'm just guessing)

Mmm this is not good, I see a bit of overlapping here :-/

Not to worry, I'm sure @moollaza will know what to do! 😃

@phalt
Copy link

phalt commented Feb 19, 2015

@MrChrisW @AkA84 Just call the /pokedex/ endpoint to get a list of all Pokémon names, you won't need to hardcode the list that way :)

There are other Pokémon triggers - I'd suggest keeping Pokemon <NAME> for now so there isn't any confusion with these.

# Triggers
triggers startend => "pokemon";

spice to => 'http://pokeapi.co/api/v1/pokemon/$1';
Copy link
Member

Choose a reason for hiding this comment

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

Please add a / at the end of $1 because http://pokeapi.co/api/v1/pokemon/pikachu redirects to it. We can't handle redirects in production machines unfortunately.

Copy link
Author

Choose a reason for hiding this comment

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

Done!

@AkA84
Copy link
Author

AkA84 commented Mar 6, 2015

@abeyang

Can you add a white backing and gray border

Done. I've also added a bit of padding so that the image has a bit of room and doesn't end up too close to the border

I don't like how it breaks the right-alignment of the text, though I think you did that to highlight the fact that it is a link.

Well actually this is how it's shown by default by the infobox, it's just how the DDG built-in template works, so I assume that it's implemented like this in another IA at least?

I would like to keep the Evolves into line in the infobox if possible as I think it belongs there at this point (for now I moved it at the top of the list so the misalignment doesn't happen in the middle of it). One possible solution would be to make visible by default the little arrow that you get when hovering over the link, and that would solve the alignment problem and also it would make more obvious to the user that that's actually a link. But I'd need also @moollaza approval for that I think since it's overriding the default behaviour. Something like this:

new-take

What do you think? Thanks!

@abeyang
Copy link
Contributor

abeyang commented Mar 7, 2015

@AkA84 unfortunately, that would break our conventions. Currently, for our info pane, we have IAs that:

--but never both. But here's another suggestion: what if we put the type inside the info pane, and move the evolution grouping into the byline? So, in your example, it might look like:

screen shot 2015-03-06 at 4 03 01 pm

What do you think?

PS: Oh, one more thing -- I think we can disable the self-linking in the title.

@AkA84
Copy link
Author

AkA84 commented Mar 7, 2015

@abeyang ok i moved things around as suggested!

One thing though about the image: I added a bit of padding around it because of the background colour, but now it doesn't look good on mobile as on smaller screens the image has a fixed height

screen

I wanted to take a look at how things are done in the IAs you put screenshot of before but with none of them I managed to get the result on the right column, I just see the image full-width. Could you help me with this?

PS: Oh, one more thing -- I think we can disable the self-linking in the title.

I'm not sure how to do this, the link is applied automatically it seems

@moollaza
Copy link
Member

@AkA84 I just found out that you can automatically produce the white background/border for an image if you set imageIsLogo: true, in your normalize function.

It also seems to handle mobile images better:

2015-03-10_15h53_00

@AkA84
Copy link
Author

AkA84 commented Mar 10, 2015

@moollaza oh that's great, I'll try it out as soon as I can thanks! Was this documented somewhere?

@moollaza
Copy link
Member

@AkA84 sadly not -- I wasn't even aware of that one! Don't worry though, we're going to be doing a big overhaul of the docs. So soon nothing will be a mystery any more!

@AkA84
Copy link
Author

AkA84 commented Mar 11, 2015

@moollaza @abeyang done, now the image looks good :)

@abeyang
Copy link
Contributor

abeyang commented Mar 19, 2015

Looks good! /cc @moollaza

moollaza added a commit that referenced this pull request Mar 20, 2015
[Instant Answer] Pokemon info
@moollaza moollaza merged commit 93ecc0b into duckduckgo:master Mar 20, 2015
@phalt
Copy link

phalt commented Mar 20, 2015

Oh my GOSH does this work now? :)

@MrChrisW
Copy link
Collaborator

@phalt Not just yet! A new version of the Spice repositories will need to be released and deployed on duckduckgo. @moollaza Will provide a link and update here once it goes live!! 👍

@phalt
Copy link

phalt commented Mar 20, 2015

@MrChrisW \o/ this is the coolest thing ever that's happened to one of my projects. @AkA84 thank you so much! I owe you a 🍺

@AkA84 AkA84 deleted the pokemon-spice branch March 24, 2015 20:52
@AkA84
Copy link
Author

AkA84 commented Mar 24, 2015

@phalt apparently it's live https://duckduckgo.com/?q=pikachu+pokemon&ia=pokedex ! 😄

@phalt
Copy link

phalt commented Mar 24, 2015

@AkA84 Woo!

@moollaza
Copy link
Member

@AkA84 you beat me to it! It went live today 👍

Thanks again for taking the time to contribute! We really appreciate it. Feel free to stick around and comment/help on other PR's & Issues or even submit more Instant Answers!

@phalt
Copy link

phalt commented Mar 26, 2015

I've seen an uptick in hits (now around 100k a day, was at around 40k) and the server is handling it just fine :)

@moollaza
Copy link
Member

@phalt that's awesome -- I'm wondering if we're severely over triggering now though. I just realized we're not checking to see if the remainder is only a single word -- we should probably do that so we don't send you API request for irrelevant queries like "pokemon movie release date"

All Pokemon names are a single word right? i.e. if the remainder has a space in it, we can bail?

/cc @AkA84

@phalt
Copy link

phalt commented Mar 26, 2015

@moollaza Yes, no spaces. Single word.

@moollaza
Copy link
Member

@phalt thanks for confirming!

@AkA84 would you be interested in adding that^ fix?

@AkA84
Copy link
Author

AkA84 commented Mar 26, 2015

@moollaza #1693 :)

@moollaza
Copy link
Member

@AkA84 awesome thanks for making that! @phalt I'll be releasing this evening, should see the changes go live within the next few days.

@AkA84
Copy link
Author

AkA84 commented Apr 6, 2015

@moollaza any news on when the IA will be back live? Is there anything i can do on my end?

@moollaza
Copy link
Member

moollaza commented Apr 7, 2015

Sorry for the delay. It will be live again with the next deploy, that should be some time this week!

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

Successfully merging this pull request may close these issues.

7 participants