Skip to content

Commit

Permalink
updated query to grab featured blog pages in the correct order (#13122)
Browse files Browse the repository at this point in the history
* updated query to grab featured blog pages in the correct order

* updated test to account for extra queries
  • Loading branch information
danielfmiranda authored Nov 15, 2024
1 parent 589aa1a commit ee6dd9d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion network-api/networkapi/nav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def localized_featured_blog_topics(self):
def localized_featured_blog_posts(self):
default_locale = settings.LANGUAGE_CODE
posts = BlogPage.objects.filter(
featured_pages_relationship__isnull=False, locale__language_code=default_locale
featured_pages_relationship__page=self.blog_index_page, locale__language_code=default_locale
).order_by("featured_pages_relationship__sort_order")
posts = localize_queryset(posts, preserve_order=True).prefetch_related("topics")
return posts[:3]
Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/nav/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def setUp(self):

def test_localized_featured_posts(self) -> None:
# Get the localised posts:
with self.assertNumQueries(4):
with self.assertNumQueries(6):
posts = self.menu.localized_featured_blog_posts
self.assertEqual(len(posts), 3)

Expand Down

0 comments on commit ee6dd9d

Please sign in to comment.