Skip to content

Commit

Permalink
feat(api): Add searching for org projects by slug(s) (#13513)
Browse files Browse the repository at this point in the history
This allows the organization projects API to search for projects by slug(s).
  • Loading branch information
billyvg authored Jun 4, 2019
1 parent 3929d31 commit 11b1cfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sentry/api/endpoints/organization_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def get(self, request, organization):
queryset = queryset.filter(Q(name__icontains=value) | Q(slug__icontains=value))
elif key == 'id':
queryset = queryset.filter(id__in=value)
elif key == 'slug':
queryset = queryset.filter(slug__in=value)
elif key == "team":
team_list = list(Team.objects.filter(slug__in=value))
queryset = queryset.filter(teams__in=team_list)
Expand Down
16 changes: 16 additions & 0 deletions tests/sentry/api/endpoints/test_organization_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ def test_search_by_ids(self):

self.check_valid_response(response, [project_bar, project_foo])

def test_search_by_slugs(self):
self.login_as(user=self.user)

project_bar = self.create_project(teams=[self.team], name='bar', slug='bar')
project_foo = self.create_project(teams=[self.team], name='foo', slug='foo')
self.create_project(teams=[self.team], name='baz', slug='baz')

path = u'{}?query=slug:{}'.format(self.path, project_foo.slug)
response = self.client.get(path)
self.check_valid_response(response, [project_foo])

path = u'{}?query=slug:{} slug:{}'.format(self.path, project_bar.slug, project_foo.slug)
response = self.client.get(path)

self.check_valid_response(response, [project_bar, project_foo])

def test_bookmarks_appear_first_across_pages(self):
self.login_as(user=self.user)

Expand Down

0 comments on commit 11b1cfa

Please sign in to comment.