perf(retention): only clean up hashtags of evicted objects
Each run scanned the whole hashtags table. Collect the hashtag ids of the objects about to be deleted and check just those.
This commit is contained in:
parent
5067fd6d96
commit
75b158c1d0
2 changed files with 57 additions and 20 deletions
|
|
@ -488,5 +488,23 @@ defmodule Pleroma.RetentionTest do
|
|||
|
||||
refute Pleroma.Hashtag.get_by_name("lonelytag")
|
||||
end
|
||||
|
||||
test "only cleans up hashtags of the evicted objects", %{old_date: old_date} do
|
||||
remote_user = insert(:user, local: false)
|
||||
local_user = insert(:user)
|
||||
|
||||
old_remote_post(remote_user, old_date, %{status: "#gone #shared #followed"})
|
||||
{:ok, _} = CommonAPI.post(local_user, %{status: "#shared"})
|
||||
{:ok, followed} = Pleroma.Hashtag.get_or_create_by_name("followed")
|
||||
{:ok, _} = Pleroma.User.follow_hashtag(local_user, followed)
|
||||
{:ok, _} = Pleroma.Hashtag.get_or_create_by_name("unrelated")
|
||||
|
||||
assert %{contexts: 1} = Retention.run()
|
||||
|
||||
refute Pleroma.Hashtag.get_by_name("gone")
|
||||
assert Pleroma.Hashtag.get_by_name("shared")
|
||||
assert Pleroma.Hashtag.get_by_name("followed")
|
||||
assert Pleroma.Hashtag.get_by_name("unrelated")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue