aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2021-01-25 20:12:09 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2021-01-25 20:12:09 +0300
commitea4785213a449f3bcd68bcb4ecb3bb6d794736b1 (patch)
tree572d43c87b712d52b06aa8fdcb21bb88d7b737f2
parentf264d930cc00c463d0f506a94f6f6b494aab7022 (diff)
downloadpleroma-ea4785213a449f3bcd68bcb4ecb3bb6d794736b1.tar.gz
[#3213] Switched to using embedded hashtags in Object.hashtags/1
(to avoid extra joins / preload in timeline queries).
-rw-r--r--lib/pleroma/config.ex1
-rw-r--r--lib/pleroma/object.ex18
2 files changed, 5 insertions, 14 deletions
diff --git a/lib/pleroma/config.ex b/lib/pleroma/config.ex
index ceb8c8b5a..0a6ac0ad0 100644
--- a/lib/pleroma/config.ex
+++ b/lib/pleroma/config.ex
@@ -98,7 +98,6 @@ defmodule Pleroma.Config do
def improved_hashtag_timeline_path, do: [:instance, :improved_hashtag_timeline]
def improved_hashtag_timeline, do: get(improved_hashtag_timeline_path())
- def object_embedded_hashtags?, do: !improved_hashtag_timeline()
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 9b5c1bec1..9edf43e04 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -388,24 +388,16 @@ defmodule Pleroma.Object do
def tags(_), do: []
def hashtags(%Object{} = object) do
- cond do
- Config.object_embedded_hashtags?() ->
- embedded_hashtags(object)
-
- object.id == "pleroma:fake_object_id" ->
- []
-
- true ->
- hashtag_records = Repo.preload(object, :hashtags).hashtags
- Enum.map(hashtag_records, & &1.name)
- end
+ # Note: always using embedded hashtags regardless whether they are migrated to hashtags table
+ # (embedded hashtags stay in sync anyways, and we avoid extra joins and preload hassle)
+ embedded_hashtags(object)
end
- defp embedded_hashtags(%Object{data: data}) do
+ def embedded_hashtags(%Object{data: data}) do
object_data_hashtags(data)
end
- defp embedded_hashtags(_), do: []
+ def embedded_hashtags(_), do: []
def object_data_hashtags(%{"tag" => tags}) when is_list(tags) do
tags