mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
split out code to dedupe tags
This commit is contained in:
parent
f32ef0a292
commit
0eba98bffd
1 changed files with 18 additions and 15 deletions
33
Rakefile
33
Rakefile
|
@ -184,6 +184,24 @@ task :primenewstriperunonlyonce => [:environment] do
|
|||
|
||||
end
|
||||
|
||||
desc 'dedupe tags'
|
||||
task :dedupetags => [:environment] do
|
||||
Tag.all.each do |tag|
|
||||
begin
|
||||
tag.reload
|
||||
rescue Sequel::Error => e
|
||||
next if e.message =~ /Record not found/
|
||||
end
|
||||
|
||||
matching_tags = Tag.exclude(id: tag.id).where(name: tag.name).all
|
||||
|
||||
matching_tags.each do |matching_tag|
|
||||
DB[:sites_tags].where(tag_id: matching_tag.id).update(tag_id: tag.id)
|
||||
matching_tag.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Clean tags'
|
||||
task :cleantags => [:environment] do
|
||||
|
||||
|
@ -208,21 +226,6 @@ task :cleantags => [:environment] do
|
|||
end
|
||||
end
|
||||
|
||||
Tag.all.each do |tag|
|
||||
begin
|
||||
tag.reload
|
||||
rescue Sequel::Error => e
|
||||
next if e.message =~ /Record not found/
|
||||
end
|
||||
|
||||
matching_tags = Tag.exclude(id: tag.id).where(name: tag.name).all
|
||||
|
||||
matching_tags.each do |matching_tag|
|
||||
DB[:sites_tags].where(tag_id: matching_tag.id).update(tag_id: tag.id)
|
||||
matching_tag.delete
|
||||
end
|
||||
end
|
||||
|
||||
Tag.where(name: 'porn').first.update is_nsfw: true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue