make files and journal level fake data
This commit is contained in:
parent
3d1fb48489
commit
ccd314a137
Binary file not shown.
After Width: | Height: | Size: 959 KiB |
Binary file not shown.
After Width: | Height: | Size: 1023 KiB |
Binary file not shown.
After Width: | Height: | Size: 720 KiB |
Binary file not shown.
After Width: | Height: | Size: 1023 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
53
db/seeds.rb
53
db/seeds.rb
|
@ -5,6 +5,8 @@ require 'json'
|
|||
CoAuthor.destroy_all
|
||||
CoAuthorRelation.destroy_all
|
||||
WritingJournal.destroy_all
|
||||
WritingJournalFile.destroy_all
|
||||
JournalLevelType.destroy_all
|
||||
|
||||
data = File.read("db/data")
|
||||
data_json = JSON.parse(data)
|
||||
|
@ -17,9 +19,32 @@ name_en = name_en.map do |p| Faker::Name::name end
|
|||
email = Array.new 51,""
|
||||
email= email.map do |p| Faker::Internet.email end
|
||||
|
||||
type = ["friend0", "teacher0", "student0", "mate0", "relation0", "friend1", "teacher1", "student1", "mate1", "relation1"]
|
||||
type = ["friend", "teacher", "student", "schoolmate", "parent", "best friend", "instructor", "labmate", "TA", "mate"]
|
||||
|
||||
file_desc = Array.new 7, ""
|
||||
file_desc = file_desc.map do |p| Faker::Lorem.word end
|
||||
|
||||
file = ["1.png", "5.pdf", "2.png", "6.pdf", "3.png", "7.pdf", "4.png"]
|
||||
|
||||
level = ["SCI", "SCIE", "SSCI", "AH & HCI", "EI", "CSCI", "CSSCI", "TSCI", "TSSCI", "THCI"]
|
||||
|
||||
FactoryGirl.define do
|
||||
factory(:journal_level, class: "JournalLevelType") do |f|
|
||||
f.sequence(:title_translations) do |n|
|
||||
{ zh_tw: "#{level[n]}",
|
||||
en: "#{level[n]}" }
|
||||
end
|
||||
end
|
||||
|
||||
factory(:upload_file, class: "WritingJournalFile") do |f|
|
||||
f.sequence(:file) do |n|
|
||||
File.new(File.join(Rails.root, "db" ,"files", file[Random.rand(0..6)]))
|
||||
end
|
||||
f.sequence(:title) do |n|
|
||||
"#{file_desc[Random.rand(0..6)]}"
|
||||
end
|
||||
end
|
||||
|
||||
factory(:type, class: "CoAuthorRelation") do |f|
|
||||
f.sequence(:relation_translations) do |n|
|
||||
{ zh_tw: "#{type[n%type.size]}",
|
||||
|
@ -85,20 +110,40 @@ FactoryGirl.define do
|
|||
"#{data_json[n]["abstract"].split[-3..-1].join(",")}"
|
||||
end
|
||||
|
||||
f.sequence(:journal_level_types) do |n|
|
||||
level = []
|
||||
total_levels = Random.rand(1..JournalLevelType.count)
|
||||
total_levels.times do
|
||||
level << JournalLevelType.all[Random.rand(0..JournalLevelType.count-1)]
|
||||
end
|
||||
level.uniq
|
||||
end
|
||||
|
||||
f.sequence(:writing_journal_files) do |n|
|
||||
files = []
|
||||
total_files = Random.rand(1..7)
|
||||
total_files.times do files << FactoryGirl.create(:upload_file) end
|
||||
files
|
||||
end
|
||||
f.create_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account
|
||||
f.update_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account
|
||||
end
|
||||
end
|
||||
|
||||
10.times.each do
|
||||
(level.size - 1).times do
|
||||
FactoryGirl.create(:journal_level)
|
||||
end
|
||||
|
||||
10.times do
|
||||
FactoryGirl.create(:type)
|
||||
end
|
||||
|
||||
50.times.each do
|
||||
50.times do
|
||||
FactoryGirl.create(:paper_record)
|
||||
end
|
||||
|
||||
50.times.each do
|
||||
50.times do
|
||||
FactoryGirl.create(:co_author_candidate)
|
||||
end
|
||||
|
||||
puts "Success!!!! Devin!"
|
||||
|
|
Loading…
Reference in New Issue