Fix hashtag timeline query
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
c772f9b40a
commit
59269cf07a
2 changed files with 18 additions and 9 deletions
|
|
@ -893,14 +893,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
# Note: NO extra ordering should be done on "activities.id desc nulls last" for optimal plan
|
# Note: NO extra ordering should be done on "activities.id desc nulls last" for optimal plan
|
||||||
from(
|
query =
|
||||||
[_activity, object] in query,
|
from(
|
||||||
join: hto in "hashtags_objects",
|
[_activity, object] in query,
|
||||||
on: hto.object_id == object.id,
|
join: hto in "hashtags_objects",
|
||||||
where: hto.hashtag_id in ^hashtag_ids,
|
on: hto.object_id == object.id,
|
||||||
distinct: [desc: object.id],
|
where: hto.hashtag_id in ^hashtag_ids
|
||||||
order_by: [desc: object.id]
|
)
|
||||||
)
|
|
||||||
|
if query.distinct == [] do
|
||||||
|
from([activity, object] in query,
|
||||||
|
distinct: [desc: activity.id],
|
||||||
|
order_by: [desc: activity.id]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
query
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_hashtag_any(query, %{tag: tag}) when is_binary(tag) do
|
defp restrict_hashtag_any(query, %{tag: tag}) when is_binary(tag) do
|
||||||
|
|
|
||||||
|
|
@ -912,7 +912,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
||||||
|
|
||||||
any_test = get(conn, "/api/v1/timelines/tag/test?any[]=test1")
|
any_test = get(conn, "/api/v1/timelines/tag/test?any[]=test1")
|
||||||
|
|
||||||
[status_none, status_test1, status_test] = json_response_and_validate_schema(any_test, :ok)
|
[status_none, status_test1, status_test] =
|
||||||
|
json_response_and_validate_schema(any_test, :ok)
|
||||||
|
|
||||||
assert to_string(activity_test.id) == status_test["id"]
|
assert to_string(activity_test.id) == status_test["id"]
|
||||||
assert to_string(activity_test1.id) == status_test1["id"]
|
assert to_string(activity_test1.id) == status_test1["id"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue