[#3213] Switched to using embedded hashtags in Object.hashtags/1
authorIvan Tashkinov <ivantashkinov@gmail.com>
Mon, 25 Jan 2021 17:12:09 +0000 (20:12 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Mon, 25 Jan 2021 17:12:09 +0000 (20:12 +0300)
(to avoid extra joins / preload in timeline queries).

lib/pleroma/config.ex
lib/pleroma/object.ex

index ceb8c8b5afdf91917444a843375a7f8ef63a3a4d..0a6ac0ad083062ee9fb71368af74a6f5c531727b 100644 (file)
@@ -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], [])
 
index 9b5c1bec1782c331c608b77a04c15e6e84cc5896..9edf43e04a9ad294721e38b69ce08d4f7a04dab2 100644 (file)
@@ -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