diff --git a/db/files/1.png b/db/files/1.png new file mode 100644 index 00000000..13112718 Binary files /dev/null and b/db/files/1.png differ diff --git a/db/files/2.png b/db/files/2.png new file mode 100644 index 00000000..4e80d728 Binary files /dev/null and b/db/files/2.png differ diff --git a/db/files/3.png b/db/files/3.png new file mode 100644 index 00000000..88291d35 Binary files /dev/null and b/db/files/3.png differ diff --git a/db/files/4.png b/db/files/4.png new file mode 100644 index 00000000..4e80d728 Binary files /dev/null and b/db/files/4.png differ diff --git a/db/files/5.pdf b/db/files/5.pdf new file mode 100644 index 00000000..b2c1a099 Binary files /dev/null and b/db/files/5.pdf differ diff --git a/db/files/6.pdf b/db/files/6.pdf new file mode 100644 index 00000000..c94c4b26 Binary files /dev/null and b/db/files/6.pdf differ diff --git a/db/files/7.pdf b/db/files/7.pdf new file mode 100644 index 00000000..91ac612a Binary files /dev/null and b/db/files/7.pdf differ diff --git a/db/seeds.rb b/db/seeds.rb index c9dd1c3d..d1e6e92b 100644 --- a/db/seeds.rb +++ b/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!"