Clean up the /scripts directory
Not removing anything, just organizing scripts into subdirectories to make it a bit more readable.
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "../config/environment"
|
||||
|
||||
ApplicationRecord.with_each_tenant do |tenant|
|
||||
User.find_each do |user|
|
||||
search_queries = Set.new
|
||||
to_delete = []
|
||||
user.search_queries.find_each do |search_query|
|
||||
if search_queries.include?(search_query.terms)
|
||||
to_delete << search_query
|
||||
end
|
||||
|
||||
search_queries << search_query.terms
|
||||
end
|
||||
|
||||
to_delete.each(&:destroy)
|
||||
end
|
||||
end
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "../config/environment"
|
||||
|
||||
ApplicationRecord.with_each_tenant do |tenant|
|
||||
Account.find_each do |account|
|
||||
tags_grouped_by_title = account.tags.group_by { |tag| tag.title.downcase }
|
||||
|
||||
tags_grouped_by_title.each do |title, tags|
|
||||
if tags.length > 1
|
||||
to_keep, to_merge = tags.first, tags[1..]
|
||||
|
||||
to_merge.each do |tag_to_merge|
|
||||
tag_to_merge.cards.each do |card|
|
||||
to_keep.cards << card unless to_keep.cards.include?(card)
|
||||
end
|
||||
|
||||
tag_to_merge.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user