aliases: retire artist aliases after 2 years.

Automatically retire artist aliases after they're more than 2 years old.
Before the rule was that artist aliases were only retired if they didn't
have any new posts in the last 2 years.
This commit is contained in:
evazion
2022-09-12 02:16:35 -05:00
parent 2c37fdf9e8
commit e1fb219738
2 changed files with 8 additions and 4 deletions

View File

@@ -40,15 +40,15 @@ module TagRelationshipRetirementService
end
def inactive_relationships
(inactive_aliases + inactive_implications).uniq
(inactive_gentag_aliases + inactive_artist_aliases + inactive_implications).uniq
end
def inactive_implications
TagImplication.active.empty.where.not(consequent_name: "banned_artist")
end
def inactive_aliases
aliases = TagAlias.general.or(TagAlias.artist).active.where("tag_aliases.created_at < ?", THRESHOLD.ago)
def inactive_gentag_aliases
aliases = TagAlias.general.active.where("tag_aliases.created_at < ?", THRESHOLD.ago)
aliases = aliases.select do |tag_alias|
!tag_alias.consequent_tag.posts.exists?(["created_at > ?", THRESHOLD.ago])
end
@@ -56,4 +56,8 @@ module TagRelationshipRetirementService
aliases += TagAlias.active.empty
aliases
end
def inactive_artist_aliases
TagAlias.active.artist.where("tag_aliases.created_at < ?", THRESHOLD.ago)
end
end

View File

@@ -51,7 +51,7 @@ class RetireTagRelationshipsJobTest < ActiveJob::TestCase
RetireTagRelationshipsJob.perform_now
assert_equal(false, ta0.reload.is_retired?)
assert_equal(true, ta0.reload.is_retired?)
assert_equal(false, ta1.reload.is_retired?)
assert_equal(false, ta2.reload.is_retired?)
assert_equal(false, ta3.reload.is_retired?)