Skip to content

Fixes #592 - Use the Issues API for label filtering of issues. #606

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

Merged
merged 1 commit into from
Apr 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions webcompat/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,9 @@ def get_search_results(query_string=None, params=None):
def get_category_from_search(issue_category):
'''XHR endpoint to get issues categories from GitHub's Search API.

There is some overlap between /issues/category/<issue_category> as used on
the home page - but this endpoint returns paginated results.

Note: until GitHub fixes a bug where requesting issues filtered by labels
doesn't return pagination via Link, we get those results from this
endpoint. Once it's fixed, we can get "contactready", "needsdiagnosis"
and "sitewait" issues from /issues/category/<issue_category>.
It's also possible to use /issues/category/<issue_category> for a category
that maps to a label. This uses the Issues API, which is less costly than
the Search API.
'''
category_list = ['contactready', 'needscontact',
'needsdiagnosis', 'sitewait']
Expand Down
12 changes: 7 additions & 5 deletions webcompat/static/js/lib/issue-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,19 +455,21 @@ issueList.IssueView = Backbone.View.extend({
// depending on what category was clicked (or if a search came in),
// update the collection instance url property and fetch the issues.

// note: until GitHub fixes a bug where requesting issues filtered by labels
// doesn't return pagination via Link, we get those results via the Search API.
var searchCategories = ['new', 'contactready', 'needsdiagnosis', 'sitewait'];
// new is a special category that must be retrieved via the Search API,
// rather than the Issues API (which can return results for labels)
var searchAPICategories = ['new'];
var issuesAPICategories = ['closed', 'contactready', 'needsdiagnosis',
'needscontact', 'sitewait'];
var params = this.issues.params;

// note: if query is the empty string, it will load all issues from the
// '/api/issues' endpoint (which I think we want).
if (category && category.query) {
params = $.extend(params, {q: category.query});
this.issues.setURLState('/api/issues/search', params);
} else if (_.contains(searchCategories, category)) {
} else if (_.contains(searchAPICategories, category)) {
this.issues.setURLState('/api/issues/search/' + category, params);
} else if (category === "closed") {
} else if (_.contains(issuesAPICategories, category)) {
this.issues.setURLState('/api/issues/category/' + category, params);
} else {
this.issues.setURLState('/api/issues', params);
Expand Down