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

Added enum ItemStateFilter to differentiate between search and list APIs #1140

Merged
merged 17 commits into from
Mar 29, 2016

Conversation

prayankmathur
Copy link
Contributor

Fixes #1082
I have added an enum "ItemStateFilter"
and tried to explain it in the xml docs.
You can review it.

@ryangribble
Copy link
Contributor

so after having a look at the changes on the PR I have to say that I am backflipping a little on what i said in the issue #1082 !!

It looks like almost all usages of ItemState only allow values of Open or Closed. Eg issues, milestones and pull request objects, as well as the NewXXX and UpdateXXX Request classes for these. It doesn't really make sense to me, to use an enum called ItemStateFilter (that s described as being used for search filtering) on all of these objects and new/update message classes. It looks like pretty much the ONLY place that seems to allow All as an option to State is the List Issues/Milestones/Pull Requests type calls.

So Im wondering if perhaps we should:

  • Keep ItemState enum but flag the All value as [Deprecated] (to be removed in future)
  • Keep using this ItemState enum on all the existing places such as Issue Milestone and PullRequest objects and the NewXXX UpdateXXX request classes for them
  • Introduce the new ItemStateFilter enum, allowing open,closed,all and use it only on the `XXXRequest`` classes that are used for the "list" methods

That means less "overall" change, and the more sensible approach that ItemState is used for actual items and creating/updating them... whilst the ItemStateFilter is used when listing them

@prayankmathur
Copy link
Contributor Author

@ryangribble
So basically, just reverse the names of the enum !! :P

@ryangribble
Copy link
Contributor

Yep pretty much, and [Obsolete] the ItemState.All item

@prayankmathur
Copy link
Contributor Author

@ryangribble
But then we come back to the same issue, that the user who is using octokit doesn't get all the issues on using ItemState.All

@ryangribble
Copy link
Contributor

@ryangribble
But then we come back to the same issue, that the user who is using octokit doesn't get all the issues on using ItemState.All

I'm not sure I follow? The search API would no longer take ItemState as an option (it would be ItemStateFilter) so they wouldn't be able to specify it anymore?

@prayankmathur
Copy link
Contributor Author

@ryangribble

I have made the changes. Take a look.

@ryangribble
Copy link
Contributor

hi @prayankmathur, as with the other PR it would be great if you could give this one a nice title and description when you can! 😀

In terms of your latest changes, Im still seeing several uses of ItemStateFilter where I dont think they are valid.

To recap:
ItemStateFilter allows values Open, Closed, All and is used on operations that can accept all 3 values - namely the "List" calls under Issues, Milestones, PullRequest API clients
(eg client.Issues.GetAll(new IssueRequest(State: ItemStateFilter.All))

ItemState allows only Open and Closed (with "All" being marked [Deprecated], to be removed next release) and is used on operations where only Open or Closed are valid states.
The Search API client is the example that triggered this issue to be raised,
eg client.Search.SearchIssues(new SearchIssuesRequest(State: ItemState.Open))
however there are also several other use cases, such as updating an Issue/Milestone/PullRequest and creating a Milestone where the state can only be open or closed.

Your latest changes show IssueUpdate MilestoneUpdate NewMilestone and PullRequestUpdate classes as all using ItemStateFilter but shouldn't they be using ItemState since only open and closed are valid values for all of these?

@prayankmathur prayankmathur changed the title Fixed issue 1082 Added enum ItemStateFilter to differentiate between search and list APIs Mar 14, 2016
@prayankmathur
Copy link
Contributor Author

@ryangribble
Thanks for clearing that out. I got a little confused.
I have made the necessary changes.
Take a look.

And i hope you like the title. 😀

/// </summary>
public ItemState State { get; protected set; }

/// <summary>
/// Whether the issue is open or close
/// </summary>
public ItemStateFilter FilteredState {get; protected set;}
Copy link
Contributor

Choose a reason for hiding this comment

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

This property shouldnt be needed

@ryangribble
Copy link
Contributor

Looking really good!

Down to very nitpick type comments now... Ive flagged a few whitespace and XmlDoc tidy ups

The TravisCI build failure on linux was an environmental issue and not related to your changes... I've given it a kick

@shiftkey - im thinking since this is a breaking change anyhow (replacing ItemState with ItemStateFilter on the xxxSearch Request objects)... perhaps there is no need to Obselete the ItemState.All value and we can simply remove it as part of the breaking change. There shouldn't really be anyone using ItemState.All on Issue/PR/Milestone update/create anyway since it isn't a valid operation (not sure how the API handles it if requested actually!). Do you agree with not needing to Obsolete ItemState.All ?

/// <summary>
/// All the issues. The option is Obsolete
/// </summary>
[Obsolete("The method is Obsolete. Dont specify the state in case of all queries")]
Copy link
Contributor

Choose a reason for hiding this comment

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

As per my other comment Im thinking we actually can just remove this guy and not need to Obsolete it, since we are making a breaking change anyway. Waiting for @shiftkey to confirm. If we DO need to obsolete it though, the warning message should be reworded, since this is not a "method". Something like

This value is obsolete and will be removed in a future version. For Request operations please use ItemStateFilter.All. For Search, Create and Update operations, "all" is not a valid option.

@@ -121,23 +121,45 @@ public enum IssueFilter
}

/// <summary>
/// The range of states that an issue can be in.
/// Range of states for "Issues", "Milestones" and "Pull Request" API.
Copy link
Member

Choose a reason for hiding this comment

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

Don't worry about the quotation marks here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shiftkey Removed the quotation marks. 😄

@@ -64,7 +64,7 @@ public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, I
public int Number { get; protected set; }

/// <summary>
/// Whether the issue is open or closed.
/// Whether the issue is "open", "closed" or "all".
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to [Obsolete] All here, or just remove it, we should update the docs accordingly...

@shiftkey
Copy link
Member

Just one more code comment to tidy up and I think this is good.

@ryangribble how does this read for the breaking changes documentation:

Decoupled request and response models usage of ItemState enum due to API rules. When querying for issues, milestones or pull requests these now use ItemStateFilter, and response models continue to use ItemState.

@prayankmathur
Copy link
Contributor Author

@shiftkey
Which one ?
The one you mentioned in the diff ?

@shiftkey
Copy link
Member

@prayankmathur correct, this one #1140 (comment)

@prayankmathur
Copy link
Contributor Author

@shiftkey
Will remove the quotation marks right away.

@prayankmathur
Copy link
Contributor Author

@shiftkey
Made the changes.Take a look.

@shiftkey
Copy link
Member

@ryangribble over to you ✊

/// </summary>
[Obsolete("The value is Obsolete and will be removed in a future release as it is not a valid option for Search, Create and Update operations")]
Copy link
Contributor

Choose a reason for hiding this comment

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

As agreed by @shiftkey we can just DROP the All option here, no need to mark it [Obsolete] anymore

@ryangribble
Copy link
Contributor

Hi guys, sorry for the delay I had a little break over the long weekend :)

It's looking great now @prayankmathur...
Ive marked up a couple of (final!) comment tweaks, and also noted that as per above, no need to [Obsolete] the ItemState.All option anymore - just 🔥 it

@prayankmathur
Copy link
Contributor Author

@ryangribble
I have made the necessary changes. Take a look.

@ryangribble
Copy link
Contributor

And with that, I think we are done with this one! Thanks for persisting through all the nitty gritty review 😆

LGTM

@ryangribble ryangribble merged commit 6455001 into octokit:master Mar 29, 2016
@prayankmathur
Copy link
Contributor Author

@ryangribble
The more I am able to improve octokit the better. 😀

@shiftkey
Copy link
Member

shiftkey commented Apr 8, 2016

release_notes: Add importers field to IMiscellaneousClient.Meta response

@hnrkndrssn
Copy link
Contributor

@shiftkey it seems this fix didn't make it in to the Breaking Changes section of the release notes (I realised as it broke a couple of my scripts after I upgraded to latest), mind having a look and adding it in there?

@shiftkey
Copy link
Member

shiftkey commented Jul 1, 2016

@alfhenrik ugh, yep, missed this one.

Thanks for letting me know, I'll edit the GitHub release to include that change...

@shiftkey
Copy link
Member

shiftkey commented Jul 1, 2016

For reference, I added this comment to the GitHub release:

ItemStateFilter has been introduced to separate it from the search APIs, which still use ItemState. This affects IssueRequest.State, PullRequestRequest.State and MilestoneRequest.State. You'll need to rename any enum usages from ItemState to ItemStateFilter.

@alfhenrik can I get a 👍 that this matches with what you were seeing?

@hnrkndrssn
Copy link
Contributor

I was using RepositoryIssueRequest but it inherits the State property from IssueRequest so all good.

@nickfloyd nickfloyd added Type: Bug Something isn't working as documented and removed category: bug labels Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants