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
1=== modified file 'src/unity_github_daemon.py'
2--- src/unity_github_daemon.py 2013-03-19 22:22:31 +0000
3+++ src/unity_github_daemon.py 2013-03-25 13:40:27 +0000
4@@ -87,9 +87,10 @@
5 return results
6 if 'repositories' in data:
7 for d in data['repositories']:
8- results.append({'uri':'https://github.com/%s/%s' % (d['owner'], d['name']),
9- 'title':'%s/%s' % (d['owner'], d['name']),
10- 'comment':d['description']})
11+ if len(results) < 25:
12+ results.append({'uri':'https://github.com/%s/%s' % (d['owner'], d['name']),
13+ 'title':'%s/%s' % (d['owner'], d['name']),
14+ 'comment':d['description']})
15 # elif 'users' in data:
16 # for d in data['users']:
17 # results.append({'uri':'https://github.com/%s' % d['username'],
18@@ -98,10 +99,11 @@
19 # 'category':1})
20 else:
21 for d in data:
22- results.append({'uri':d['html_url'],
23- 'icon':d['owner']['avatar_url'],
24- 'title':'%s/%s' % (d['owner']['login'], d['name']),
25- 'comment':d['description']})
26+ if len(results) < 25:
27+ results.append({'uri':d['html_url'],
28+ 'icon':d['owner']['avatar_url'],
29+ 'title':'%s/%s' % (d['owner']['login'], d['name']),
30+ 'comment':d['description']})
31 return results
32
33
34
35=== modified file 'tests/test_github.py'
36--- tests/test_github.py 2013-03-14 00:04:33 +0000
37+++ tests/test_github.py 2013-03-25 13:40:27 +0000
38@@ -67,6 +67,7 @@
39 results.append(result_set.results[0]['title'])
40 results.append(result_set.results[0]['comment'])
41 self.assertEqual(results, expected_results)
42+ self.assertEqual(len(result_set.results), 25)
43
44 def test_failing_search(self):
45 self.scope_module.SEARCH_URI = 'file:tests/data/mock_github_fail#'

Subscribers

People subscribed via source and target branches

to all changes: