1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-06-09 06:20:43 +00:00

Lemmy ListPosts query optimization

This commit is contained in:
BreadMakesYouFat 2023-06-26 11:48:38 -04:00
parent 30fb8e80e9
commit 7fb12fe84f

View File

@ -211,22 +211,23 @@ func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
showAll = true
}
resp := &types.GetPostsResponse{}
var getPosts types.GetPosts
if showAll {
resp, err = sys.client.Posts(context.Background(), types.GetPosts{
getPosts = types.GetPosts{
Type: types.NewOptional(types.ListingTypeSubscribed),
Sort: types.NewOptional(types.SortTypeNew),
Limit: types.NewOptional(int64(50)),
})
}
} else {
resp, err = sys.client.Posts(context.Background(), types.GetPosts{
getPosts = types.GetPosts{
Type: types.NewOptional(types.ListingTypeSubscribed),
Sort: types.NewOptional(types.SortTypeNew),
Limit: types.NewOptional(int64(50)),
CommunityID: types.NewOptional(communityID),
})
}
}
resp, err := sys.client.Posts(context.Background(), getPosts)
if err != nil {
return []post.Post{}, err
}