# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) if Rails.env.development? subjects = [ "Civil Law", "Commercial Law (or Mercantile Law)", "Labor Law", "Legal and Judicial Ethics", "Remedial Law", "Taxation Law", "Political Law", "Criminal Law" ].freeze subjects.each { |name| Cdao::Subject.create(name: name, ancestry: nil) } if Cdao::Subject.count.zero? annomarks = { "A" => "Affirmed", "C" => "Cited", "D" => "Distinguished", "F" => "Footnote", "I" => "Illustrative", "M" => "Modified", "O" => "Overruled", "CO" => "Concurring Opinion", "SO" => "Seperated Opinion" }.freeze annomarks.each { |k, v| Annomark.create(name: v, code: k) } if Annomark.count.zero? Doctrine.destroy_all Annotation.destroy_all Cdao::Subject.find_each.with_index do |subject, index| doctrine = Doctrine.new doctrine.document = Cdao::Jurisprudence.first(index + 1).last doctrine.content = Faker::Lorem.paragraph doctrine.save doctrine.subject_ids = [subject.id] annotation = doctrine.annotations.new annotation.document = Cdao::Jurisprudence.last(index + 1).first annotation.annomark_ids = [Faker::Number.between(from: Annomark.first.id, to: Annomark.last.id)] annotation.save annotation_document = annotation.annotation_documents.new annotation_document.document = Cdao::Jurisprudence.last(index + 101).first annotation_document.save end Doctrine.find_each do |doctrine| doc = doctrine.document ids = doc.doctrine_ids ids << doctrine.id doc.doctrine_ids = ids.uniq end Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/civil.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/commercial.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/criminal.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/labor.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/taxation.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/political.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/remedial.csv")) Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/legal.csv")) Doctrine.parse_csv_file(1421, Rails.root.join("data/csvs/doctrines.csv")) Doctrine.parse_csv_file(1495, Rails.root.join("data/csvs/doctrines2.csv"))