<commit_before>require File.dirname(__FILE__) + '/claim_state_advancer'
require File.dirname(__FILE__) + '/document_generator'
require File.dirname(__FILE__) + '/basic_fee_generator'
require File.dirname(__FILE__) + '/fee_generator'
require File.dirname(__FILE__) + '/expense_generator'

module DemoData

  class ClaimGenerator

    def initialize(param_options = {})
      default_options = { states: :all, num_advocates: 6, num_claims_per_state: 2 }
      options = default_options.merge(param_options)
      @states = options[:states] == :all ? Claims::StateMachine.dashboard_displayable_states : options[:states]
      @num_advocates = options[:num_advocates]
      @num_claims = options[:num_claims_per_state]
    end

    def run
      generate_advocates_if_required
      advocates = ExternalUser.advocates[0, @num_advocates]
      advocates.each do |advocate|
        @num_claims.times do
          generate_claims_for_advocate(advocate)
        end
      end
    end

  private
    def generate_claim(advocate)
      claim = Claim::AdvocateClaim.new(
        additional_information: generate_additional_info,
        apply_vat: (rand(1..4) % 4 == 0 ? false : true),
        state: "draft",
        case_number: ('A'..'Z').to_a.sample +  rand(10000000..99999999).to_s,
        advocate_category: Settings.advocate_categories.sample,
        external_user: advocate,
        court: Court.all.sample,
        offence: Offence.all.sample,
        cms_number: "CMS-2015-195-1",
        creator: advocate,
        evidence_checklist_ids: [],
        source: "web",
        vat_amount: 0.0,
        case_type: CaseType.all.sample)
      claim.save!
      puts "Added claim #{claim.id} #{claim.case_type.name} for advocate #{advocate.name}"
      add_defendants(claim)
      add_documents(claim)
      add_claim_detail(claim)
      claim.save<commit_msg>Demo data fix for case types<commit_after>require File.dirname(__FILE__) + '/claim_state_advancer'
require File.dirname(__FILE__) + '/document_generator'
require File.dirname(__FILE__) + '/basic_fee_generator'
require File.dirname(__FILE__) + '/fee_generator'
require File.dirname(__FILE__) + '/expense_generator'

module DemoData

  class ClaimGenerator

    def initialize(param_options = {})
      default_options = { states: :all, num_advocates: 6, num_claims_per_state: 2 }
      options = default_options.merge(param_options)
      @states = options[:states] == :all ? Claims::StateMachine.dashboard_displayable_states : options[:states]
      @num_advocates = options[:num_advocates]
      @num_claims = options[:num_claims_per_state]
    end

    def run
      generate_advocates_if_required
      advocates = ExternalUser.advocates[0, @num_advocates]
      advocates.each do |advocate|
        @num_claims.times do
          generate_claims_for_advocate(advocate)
        end
      end
    end

  private
    def generate_claim(advocate)
      claim = Claim::AdvocateClaim.new(
        additional_information: generate_additional_info,
        apply_vat: (rand(1..4) % 4 == 0 ? false : true),
        state: "draft",
        case_number: ('A'..'Z').to_a.sample +  rand(10000000..99999999).to_s,
        advocate_category: Settings.advocate_categories.sample,
        external_user: advocate,
        court: Court.all.sample,
        offence: Offence.all.sample,
        cms_number: "CMS-2015-195-1",
        creator: advocate,
        evidence_checklist_ids: [],
        source: "web",
        vat_amount: 0.0,
        case_type: CaseType.agfs.sample)
      claim.save!
      puts "Added claim #{claim.id} #{claim.case_type.name} for advocate #{advocate.name}"
      add_defendants(claim)
      add_documents(claim)
      add_claim_detail(claim)
      claim.save
{'fraction_non_alphanumeric': 0.10789049919484701, 'fraction_numerical': 0.017713365539452495, 'mean_word_length': 3.244874715261959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1860893', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1144, 'n_words': 214}