- # Groups by all bindings to allow aggregation on hashtags
- defp group_by_all_bindings(query) do
- # Expecting named bindings: :object, :bookmark, :thread_mute, :report_note
- cond do
- Enum.count(query.aliases) == 4 ->
- from([a, o, b3, b4, b5] in query, group_by: [a.id, o.id, b3.id, b4.id, b5.id])
-
- Enum.count(query.aliases) == 3 ->
- from([a, o, b3, b4] in query, group_by: [a.id, o.id, b3.id, b4.id])
-
- Enum.count(query.aliases) == 2 ->
- from([a, o, b3] in query, group_by: [a.id, o.id, b3.id])
-
- true ->
- from([a, o] in query, group_by: [a.id, o.id])
- end
+ defp object_ids_query_for_tags(tags) do
+ from(hto in "hashtags_objects")
+ |> join(:inner, [hto], ht in Pleroma.Hashtag, on: hto.hashtag_id == ht.id)
+ |> where([hto, ht], ht.name in ^tags)
+ |> select([hto], hto.object_id)
+ |> distinct([hto], true)