Update hashtag prune to account for followed hashtags #844

Merged
floatingghost merged 2 commits from norm/akkoma:hashtag-prune into develop 2025-01-05 15:41:23 +00:00
Showing only changes of commit 88a8086ad3 - Show all commits

Use LEFT JOIN instead of UNION for hashtag pruning
Some checks are pending
ci/woodpecker/pr/build-amd64 Pipeline is pending
ci/woodpecker/pr/build-arm64 Pipeline is pending
ci/woodpecker/pr/docs Pipeline is pending
ci/woodpecker/pr/lint Pipeline is pending
ci/woodpecker/pr/test Pipeline is pending
ci/woodpecker/pull_request_closed/build-amd64 Pipeline is pending approval
ci/woodpecker/pull_request_closed/build-arm64 Pipeline is pending approval
ci/woodpecker/pull_request_closed/docs Pipeline is pending approval
ci/woodpecker/pull_request_closed/lint Pipeline is pending approval
ci/woodpecker/pull_request_closed/test Pipeline is pending approval

Norm 2024-10-25 12:25:18 -04:00

View file

@ -343,13 +343,16 @@ defmodule Mix.Tasks.Pleroma.Database do
%{:num_rows => del_hashtags} =
"""
DELETE FROM hashtags AS ht
WHERE NOT EXISTS (
SELECT 1 FROM hashtags_objects hto
WHERE ht.id = hto.hashtag_id
UNION
SELECT 1 FROM user_follows_hashtag ufht
WHERE ht.id = ufht.hashtag_id)
DELETE FROM hashtags
USING hashtags AS ht
LEFT JOIN hashtags_objects hto
ON ht.id = hto.hashtag_id
LEFT JOIN user_follows_hashtag ufht
ON ht.id = ufht.hashtag_id
WHERE
hashtags.id = ht.id
AND hto.hashtag_id is NULL
AND ufht.hashtag_id is NULL
"""
|> Repo.query!()