Merge lp:~submarine/ubuntu-scopes/github-25-limit into lp:~submarine/ubuntu-scopes/github

Proposed by David Callé
Status: Merged
Approved by: James Henstridge
Approved revision: 21
Merged at revision: 20
Proposed branch: lp:~submarine/ubuntu-scopes/github-25-limit
Merge into: lp:~submarine/ubuntu-scopes/github
Diff against target: 45 lines (+10/-7)
2 files modified
src/unity_github_daemon.py (+9/-7)
tests/test_github.py (+1/-0)
To merge this branch: bzr merge lp:~submarine/ubuntu-scopes/github-25-limit
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
James Henstridge Approve
Review via email: mp+155149@code.launchpad.net

Commit message

Limit to 25 results for speed and ease of exploration.

Description of the change

Limit to 25 results for speed and ease of exploration.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

Won't this limit the number of results to 26? If there are 25 results, then "len(results) <= 25" is true and you'll append another result.

Also, would it be possible to update the tests to show that the results really are limited to 25?

Revision history for this message
James Henstridge (jamesh) :
review: Needs Fixing
21. By David Callé

Add test for results limit. Limit to 25, not 26.

Revision history for this message
David Callé (davidc3) wrote :

Fixed.

Revision history for this message
James Henstridge (jamesh) wrote :

Looks good

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity_github_daemon.py'
--- src/unity_github_daemon.py 2013-03-19 22:22:31 +0000
+++ src/unity_github_daemon.py 2013-03-25 13:40:27 +0000
@@ -87,9 +87,10 @@
87 return results87 return results
88 if 'repositories' in data:88 if 'repositories' in data:
89 for d in data['repositories']:89 for d in data['repositories']:
90 results.append({'uri':'https://github.com/%s/%s' % (d['owner'], d['name']),90 if len(results) < 25:
91 'title':'%s/%s' % (d['owner'], d['name']),91 results.append({'uri':'https://github.com/%s/%s' % (d['owner'], d['name']),
92 'comment':d['description']})92 'title':'%s/%s' % (d['owner'], d['name']),
93 'comment':d['description']})
93# elif 'users' in data:94# elif 'users' in data:
94# for d in data['users']:95# for d in data['users']:
95# results.append({'uri':'https://github.com/%s' % d['username'],96# results.append({'uri':'https://github.com/%s' % d['username'],
@@ -98,10 +99,11 @@
98# 'category':1})99# 'category':1})
99 else:100 else:
100 for d in data:101 for d in data:
101 results.append({'uri':d['html_url'],102 if len(results) < 25:
102 'icon':d['owner']['avatar_url'],103 results.append({'uri':d['html_url'],
103 'title':'%s/%s' % (d['owner']['login'], d['name']),104 'icon':d['owner']['avatar_url'],
104 'comment':d['description']})105 'title':'%s/%s' % (d['owner']['login'], d['name']),
106 'comment':d['description']})
105 return results107 return results
106108
107109
108110
=== modified file 'tests/test_github.py'
--- tests/test_github.py 2013-03-14 00:04:33 +0000
+++ tests/test_github.py 2013-03-25 13:40:27 +0000
@@ -67,6 +67,7 @@
67 results.append(result_set.results[0]['title'])67 results.append(result_set.results[0]['title'])
68 results.append(result_set.results[0]['comment'])68 results.append(result_set.results[0]['comment'])
69 self.assertEqual(results, expected_results)69 self.assertEqual(results, expected_results)
70 self.assertEqual(len(result_set.results), 25)
7071
71 def test_failing_search(self):72 def test_failing_search(self):
72 self.scope_module.SEARCH_URI = 'file:tests/data/mock_github_fail#'73 self.scope_module.SEARCH_URI = 'file:tests/data/mock_github_fail#'

Subscribers

People subscribed via source and target branches

to all changes: