Skip to content
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

Limit query to 20, and remove unneeded list evaluations #159

Merged
merged 2 commits into from
Dec 11, 2017
Merged
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
23 changes: 8 additions & 15 deletions councilmatic_core/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def url_with_querystring(self, path, **kwargs):

def get_object(self, request):
self.queryDict = request.GET

all_results = SearchQuerySet().all()
facets = None

Expand Down Expand Up @@ -75,13 +76,13 @@ def item_pubdate(self, bill):
def description(self, obj):
return "Bills returned from search"

def items(self, searchresults):
l_items = list(searchresults)[:20]
def items(self, query):
l_items = query[:20]
# turn these into bills. XXX: should override in subclasses, e.g. NYCCouncilmaticFacetedSearchFeed,
# to access methods like inferred_status()
pks = [i.pk for i in l_items]
bills = self.bill_model.objects.filter(pk__in=pks).order_by('-last_action_date')
return list(bills)
return bills


class PersonDetailFeed(Feed):
Expand Down Expand Up @@ -156,9 +157,7 @@ def description(self, obj):
return "Events for committee %s" % obj.name

def items(self, obj):
events = obj.recent_events.all()[:self.NUM_RECENT_COMMITTEE_EVENTS]
levents = list(events)
return levents
return obj.recent_events.all()[:self.NUM_RECENT_COMMITTEE_EVENTS]


class CommitteeDetailActionFeed(Feed):
Expand Down Expand Up @@ -194,9 +193,7 @@ def description(self, obj):
return "Actions for committee %s" % obj.name

def items(self, obj):
actions = obj.recent_activity[:self.NUM_RECENT_COMMITTEE_ACTIONS]
actions_list = list(actions)
return actions_list
return obj.recent_activity[:self.NUM_RECENT_COMMITTEE_ACTIONS]


class BillDetailActionFeed(Feed):
Expand Down Expand Up @@ -232,9 +229,7 @@ def description(self, obj):
return "Actions for bill %s" % obj.friendly_name

def items(self, obj):
actions = obj.ordered_actions[:self.NUM_RECENT_BILL_ACTIONS]
actions_list = list(actions)
return actions_list
return obj.ordered_actions[:self.NUM_RECENT_BILL_ACTIONS]


class EventsFeed(Feed):
Expand All @@ -261,6 +256,4 @@ def description(self, obj):
return "Events"

def items(self, obj):
events = Event.objects.all()[:self.NUM_RECENT_EVENTS]
levents = list(events)
return levents
return Event.objects.all()[:self.NUM_RECENT_EVENTS]