Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Avoid listifying index pages when counting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Jul 8, 2015
1 parent a3f9a3d commit c8dc050
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go/base/management/commands/go_account_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def handle_stats(self, user, api, options):
def _count_results(self, index_page):
count = 0
while index_page is not None:
count += len(list(index_page))
count += len(index_page)
index_page = index_page.next_page()
return count

Expand Down
2 changes: 1 addition & 1 deletion go/base/tests/test_go_manage_message_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def assert_batches_cleared(self, batches):
def count_results(self, index_page):
count = 0
while index_page is not None:
count += len(list(index_page))
count += len(index_page)
index_page = index_page.next_page()
return count

Expand Down
2 changes: 1 addition & 1 deletion go/contacts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def _people(request):
else:
keys = contact_store.list_contacts_page(max_results=fetch_limit)

key_count = len(list(keys))
key_count = len(keys)
limit = min(int(request.GET.get('limit', 100)), key_count)
# If we have a continuation token, it means there are more than
# `fetch_limit` keys.
Expand Down
4 changes: 2 additions & 2 deletions go/vumitools/contact/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_get_static_contact_keys_for_group(self):
contact_keys.add(contact.key)

index_page = yield store.get_static_contact_keys_for_group(group)
self.assertEqual(len(list(index_page)), 2)
self.assertEqual(len(index_page), 2)
self.assertEqual(index_page.has_next_page(), False)

@inlineCallbacks
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_get_contact_keys_for_group_static(self):
contact_keys.add(contact.key)

index_page = yield store.get_contact_keys_for_group(group)
self.assertEqual(len(list(index_page)), 2)
self.assertEqual(len(index_page), 2)
self.assertEqual(index_page.has_next_page(), False)

@inlineCallbacks
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
author_email='dev@praekeltfoundation.org',
packages=find_packages(),
install_requires=[
'vumi>=0.5.20',
'vumi>=0.5.21',
'vxsandbox>=0.5.0',
'vxpolls',
'vumi-wikipedia>=0.2.1',
Expand Down

0 comments on commit c8dc050

Please sign in to comment.