mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-29 02:31:00 +00:00
Improve performance on /api/v1/timelines/home (#387)
Prefetch/select required fields for API version of home. Requires considerably more data than HTML version of home.
This commit is contained in:
parent
150cd9503d
commit
28cfbf2ef5
1 changed files with 13 additions and 0 deletions
|
@ -21,6 +21,19 @@ def home(
|
|||
# Grab a paginated result set of instances
|
||||
paginator = MastodonPaginator()
|
||||
queryset = TimelineService(request.identity).home()
|
||||
queryset = queryset.select_related(
|
||||
"subject_post_interaction__post",
|
||||
"subject_post_interaction__post__author",
|
||||
"subject_post_interaction__post__author__domain",
|
||||
)
|
||||
queryset = queryset.prefetch_related(
|
||||
"subject_post__mentions__domain",
|
||||
"subject_post_interaction__post__attachments",
|
||||
"subject_post_interaction__post__mentions",
|
||||
"subject_post_interaction__post__emojis",
|
||||
"subject_post_interaction__post__mentions__domain",
|
||||
"subject_post_interaction__post__author__posts",
|
||||
)
|
||||
pager = paginator.paginate_home(
|
||||
queryset,
|
||||
min_id=min_id,
|
||||
|
|
Loading…
Reference in a new issue