Skip to content

Commit

Permalink
Simpler queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jberghoef authored and mvantellingen committed Jun 2, 2017
1 parent f21c423 commit aafc8c4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/wagtail_personalisation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,15 @@ def get_active_days(self):

def get_used_pages(self):
"""Return the pages that have variants using this segment."""
pages = [page for page
in PersonalisablePageMetadata.objects.filter(segment=self)]
pages = list(PersonalisablePageMetadata.objects.filter(segment=self))

return pages

def get_created_variants(self):
"""Return the variants using this segment."""
pages = [page.variations for page
in PersonalisablePageMetadata.objects.filter(segment=self)]
pages = Page.objects.filter(_personalisable_page_metadata__segment=self)

return list(itertools.chain(*pages))
return pages

def get_rules(self):
"""Retrieve all rules in the segment."""
Expand Down

0 comments on commit aafc8c4

Please sign in to comment.