forked from miaoski/amis-safolu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-dummy-in-db.rb
More file actions
31 lines (27 loc) · 869 Bytes
/
Copy pathclean-dummy-in-db.rb
File metadata and controls
31 lines (27 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'pry'
require './models/application_record.rb'
require './models/definition'
require './models/description'
require './models/example'
require './models/synonym'
# 執行順序不可更換
Synonym.where(content: '').destroy_all
puts "clean Description"
Description.where(content: '').each do |description|
if description.examples.blank? && description.synonyms.blank?
puts description.id
description.destroy
end
end
Description.where(content: '。').each do |description|
if description.examples.blank? && description.synonyms.blank?
puts description.id
description.destroy
end
end
puts "clean Definition"
definition_ids = Definition.pluck(:id)
definition_ids_from_description = Description.distinct.pluck(:definition_id)
diff = definition_ids-definition_ids_from_description
puts diff.inspect
Definition.where(id: diff).destroy_all