mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
add back tag dedupe code
This commit is contained in:
parent
4fc5698d0e
commit
4eeec12b67
2 changed files with 19 additions and 1 deletions
18
Rakefile
18
Rakefile
|
@ -238,3 +238,21 @@ task :generate_sitemap => [:environment] do
|
||||||
gz.write %{</sitemapindex>}
|
gz.write %{</sitemapindex>}
|
||||||
end
|
end
|
||||||
end
|
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
|
|
@ -904,7 +904,7 @@ class Site < Sequel::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_tag_name(name)
|
def add_tag_name(name)
|
||||||
add_tag Tag[name: name] || Tag.create(name: name)
|
add_tag Tag.find_or_create(name: name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_create
|
def before_create
|
||||||
|
|
Loading…
Add table
Reference in a new issue