Skip to content

Commit

Permalink
[FIX] A potential performance issue with an ajax call (thx to @pvyParts)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppfeufer committed Mar 5, 2024
1 parent 837c881 commit 894f08d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions afat/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ def ajax_get_recent_fatlinks(request: WSGIRequest) -> JsonResponse:
:rtype:
"""

fatlinks = (
fatlink_ids = list(
FatLink.objects.select_related_default()
.annotate_fats_count()
.order_by("-created")[:10]
.values_list("id", flat=True)
)

fatlinks = (
FatLink.objects.filter(id__in=fatlink_ids)
.order_by("-created")
.annotate_fats_count()
)

fatlink_rows = [
Expand Down

0 comments on commit 894f08d

Please sign in to comment.