Skip to content

Commit

Permalink
Update section/models.py
Browse files Browse the repository at this point in the history
Followed @psiemens suggestion on formating

Co-authored-by: Peter Siemens <[email protected]>
  • Loading branch information
SamuelmdLow and psiemens authored Oct 30, 2023
1 parent e22bf69 commit adb53c4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion section/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,14 @@ def get_section_articles(self, order='-explicit_published_at') -> QuerySet:
# return ArticlePage.objects.from_section(section_root=self)
# section_articles = ArticlePage.objects.live().public().filter(current_section=self.slug).order_by(order)
#section_articles = ArticlePage.objects.live().public().descendant_of(self).order_by(order)
section_articles = ArticlePage.objects.live().child_of(self).filter(explicit_published_at__gt=datetime.datetime.now()-datetime.timedelta(days=60)).order_by(order)
# Optimization: limit queryset to articles published in the last 60 days to shorten query time
recent_articles_delta = datetime.datetime.now()-datetime.timedelta(days=60)

section_articles = ArticlePage.objects
.live() \
.child_of(self) \
.filter(explicit_published_at__gt=recent_articles_delta) \
.order_by(order)

return section_articles

Expand Down

0 comments on commit adb53c4

Please sign in to comment.