plu / Pithub

Perl Github v3 API
http://metacpan.org/module/Pithub
Other
68 stars 36 forks source link

No way to pull issues by milestone title #180

Closed bakoontz closed 9 years ago

bakoontz commented 9 years ago

The github API docs are very misleading: While they do specify "integer" or "string" for milestone values, apparently the only string permitted is "*". It would be useful to be able to specify issue search criteria by milestone title (just as the github search functionality permits). Otherwise, the only way around this is to extract the milestone number from Issues::Milestone and pass that argument into Issues.

At the very least, the docs should expand on this, as it's not very clear from where the milestone argument comes.

schwern commented 9 years ago

If you're referring to the List issues for a repository part of the API, it works for me.™

$ perl -wle 'use Pithub; $i = Pithub->new->issues->list( user => "gr2m", repo => "milestones", params => { milestone => "02 App & Plugin Templates" } );  print $i->first->{milestone}{title}'
02 App & Plugin Templates

Could you provide code demonstrating the problem?

bakoontz commented 9 years ago

Here's an example (changing the milestone parameter to the string doesn't produce any results):

#! /usr/bin/perl
use strict;
use Pithub;

my $i = Pithub::Issues->new(auto_pagination => 1);
my $result = $i->list(
    user => 'wikkawik',
    repo => 'WikkaWiki',
    params => {
        milestone => "1.3.6",
        #milestone => 21,
        state => "closed",
        sort => "number",
        direction => "asc",
    }
);

while(my $row = $result->next) {
    print "$row->{'number'}:$row->{'title'}\n"
}
schwern commented 9 years ago

It looks like the Github API is doing a terrible job on this. I get inconsistent results, the milestone string works for some repositories, for most it doesn't. Sometimes it works for milestones with no open issues, sometimes it doesn't.

Pithub is a thin wrapper around the Github API. Bugs in the API should be fixed by Github. I'd recommend you contact them about this and get back to us when you get a response.

bakoontz commented 9 years ago

I seem to be in the wrong about this. It's clear that v3 of the github API does not support searching for milestones by milestone title, and that one needs to synthesize a mapping between milestone number and title in order to accomplish a search by title. This is the response I received from github support:

Thanks for a detailed description.

First, you're right -- the milestone parameter should be a string , a number (integer), or string none. May I ask why you're passing in a string value that is not \ or none?

Just to clarify -- both of those API calls you mentioned are succeeding, you're getting back a 200 OK response. When you pass in "1.3.6" as the milestone, that's interpreted as number 1, and when you pass in "02 App & Plugin Templates", that's interpreted as number 2. So, your queries are interpreted as ?milestone=1 and ?milestone=2. In the first case, there are no issues associated with milestone 1 which have been closed, so you get an empty array. In the second case, there are some issues associated with milestone 2 which have been closed, so you get some items back.

Does this explain the behavior you observed? Again, my suggestion would be to use milestone numbers to filter issues by milestone, and not milestone titles. You can get the number of a milestone by listing milestones for the repository:

schwern commented 9 years ago

Re-reading the API documentation, it is quite clear. I could have sworn it wasn't and thought maybe they recently changed it, but I checked the Wayback Machine and it hasn't. Also the Pithub::Issues documentation already has it correct. Reading comprehension fail all around!

Interpreting "1.3.6" as "1" is heroic to an absurd and confusing level. I would suggest to them they make it a validation error instead. I would also suggest they allow milestone names since, unlike issues, their web site refers to milestones by name and there's no API call to look up a milestone by name.

I'm going to close this out. Feel free to reopen if you feel it's not done, or open another issue if you find a related problem.