mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-31 19:36:44 +01:00
Load less data in indexing
This commit is contained in:
parent
77ed150dd9
commit
0d6bc6cee1
3 changed files with 43 additions and 10 deletions
|
@ -9,11 +9,13 @@ defmodule Philomena.Comments do
|
|||
|
||||
alias PhilomenaQuery.Search
|
||||
alias Philomena.UserStatistics
|
||||
alias Philomena.Users.User
|
||||
alias Philomena.Comments.Comment
|
||||
alias Philomena.Comments.SearchIndex, as: CommentIndex
|
||||
alias Philomena.IndexWorker
|
||||
alias Philomena.Images.Image
|
||||
alias Philomena.Images
|
||||
alias Philomena.Tags.Tag
|
||||
alias Philomena.Notifications
|
||||
alias Philomena.Versions
|
||||
alias Philomena.Reports
|
||||
|
@ -234,7 +236,18 @@ defmodule Philomena.Comments do
|
|||
end
|
||||
|
||||
def indexing_preloads do
|
||||
[:user, image: :tags]
|
||||
user_query = select(User, [u], map(u, [:id, :name]))
|
||||
tag_query = select(Tag, [t], map(t, [:id]))
|
||||
|
||||
image_query =
|
||||
Image
|
||||
|> select([i], struct(i, [:approved, :hidden_from_users, :id]))
|
||||
|> preload(tags: ^tag_query)
|
||||
|
||||
[
|
||||
user: user_query,
|
||||
image: image_query
|
||||
]
|
||||
end
|
||||
|
||||
def perform_reindex(column, condition) do
|
||||
|
|
|
@ -847,16 +847,25 @@ defmodule Philomena.Images do
|
|||
end
|
||||
|
||||
def indexing_preloads do
|
||||
user_query = select(User, [u], map(u, [:id, :name]))
|
||||
sources_query = select(Source, [s], map(s, [:image_id, :source]))
|
||||
alias_tags_query = select(Tag, [t], map(t, [:aliased_tag_id, :name]))
|
||||
|
||||
base_tags_query =
|
||||
Tag
|
||||
|> select([t], [:category, :id, :name])
|
||||
|> preload(aliases: ^alias_tags_query)
|
||||
|
||||
[
|
||||
:user,
|
||||
:favers,
|
||||
:downvoters,
|
||||
:upvoters,
|
||||
:hiders,
|
||||
:deleter,
|
||||
:gallery_interactions,
|
||||
:sources,
|
||||
tags: [:aliases, :aliased_tag]
|
||||
sources: sources_query,
|
||||
user: user_query,
|
||||
favers: user_query,
|
||||
downvoters: user_query,
|
||||
upvoters: user_query,
|
||||
hiders: user_query,
|
||||
deleter: user_query,
|
||||
tags: base_tags_query
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ defmodule Philomena.Posts do
|
|||
alias Philomena.Topics.Topic
|
||||
alias Philomena.Topics
|
||||
alias Philomena.UserStatistics
|
||||
alias Philomena.Users.User
|
||||
alias Philomena.Posts.Post
|
||||
alias Philomena.Posts.SearchIndex, as: PostIndex
|
||||
alias Philomena.IndexWorker
|
||||
|
@ -279,7 +280,17 @@ defmodule Philomena.Posts do
|
|||
end
|
||||
|
||||
def indexing_preloads do
|
||||
[:user, topic: :forum]
|
||||
user_query = select(User, [u], map(u, [:id, :name]))
|
||||
|
||||
topic_query =
|
||||
Topic
|
||||
|> select([t], struct(t, [:forum_id, :title]))
|
||||
|> preload([:forum])
|
||||
|
||||
[
|
||||
user: user_query,
|
||||
topic: topic_query
|
||||
]
|
||||
end
|
||||
|
||||
def perform_reindex(column, condition) do
|
||||
|
|
Loading…
Reference in a new issue