<commit_before>module Project::StateMachineHandler
  extend ActiveSupport::Concern

  included do
     state_machine :campaign_type, initial: :flexible do
      state :all_or_none
      state :flexible
    end

    state_machine :state, initial: :draft do
      state :draft
      state :soon
      state :rejected
      state :online
      state :successful
      state :waiting_funds
      state :failed
      state :deleted
      state :in_analysis

      event :push_to_draft do
        transition all => :draft #NOTE: when use 'all' we can't use new hash style ;(
      end

      event :push_to_soon do
        transition all => :soon #NOTE: when use 'all' we can't use new hash style ;(
      end

      event :push_to_trash do
        transition [:draft, :rejected, :in_analysis] => :deleted
      end

      event :send_to_analysis do
        transition draft: :in_analysis
      end

      event :reject do
        transition [:draft, :in_analysis] =>  :rejected
      end

      event :approve do
        transition [:draft, :soon, :in_analysis] => :online
      end

      event :finish do
        transition online: :failed,             if: ->(project) {
          !project.flexible? && project.expired? && !project.pending_contributions_reached_the_goal?
        }

        transition online: :waiting_funds,      if: ->(project) {
          project.expired? && (project.pending_contributions_reached_the_goal? || project.flexible?)
        }

        transition waiting_funds: :successful,  if: ->(project) {
          (project.reached_goal? || project.flexible?) && !project.in_time_to_wait?
        }

        transition waiting_funds: :failed,      if: ->(project) {
          !project.flexible? && project.expired? && !project.reached_goal? && !project.in_time_to_wait?
        }

        transition waiting_funds: :waiting_funds,      if: ->(project) {
          project.expired? && !project.reached_goal? && (project.in_time_to_wait?)
        }
      end

      after_transition do |project, transition|
        project.notify_observers :"from_#{transition.from}_to_#{transition.to}"
      end

      after_transition any => [:failed, :successful] do |project, transition|
        project.notify_observers :sync_with_mailchimp
      end

      after_transition [:draft, :rejected] => :deleted do |project, transition|
        project.update_attributes({ permalink: "deleted_project_#{project.id}"})
      end
    end
  end
end

<commit_msg>Improve indentation of code<commit_after>module Project::StateMachineHandler
  extend ActiveSupport::Concern

  included do
     state_machine :campaign_type, initial: :flexible do
      state :all_or_none
      state :flexible
    end

    state_machine :state, initial: :draft do
      state :draft
      state :soon
      state :rejected
      state :online
      state :successful
      state :waiting_funds
      state :failed
      state :deleted
      state :in_analysis

      event :push_to_draft do
        transition all => :draft #NOTE: when use 'all' we can't use new hash style ;(
      end

      event :push_to_soon do
        transition all => :soon #NOTE: when use 'all' we can't use new hash style ;(
      end

      event :push_to_trash do
        transition [:draft, :rejected, :in_analysis] => :deleted
      end

      event :send_to_analysis do
        transition draft: :in_analysis
      end

      event :reject do
        transition [:draft, :in_analysis] =>  :rejected
      end

      event :approve do
        transition [:draft, :soon, :in_analysis] => :online
      end

      event :finish do
        transition online: :failed,               if: ->(project) {
          !project.flexible? && project.expired? && !project.pending_contributions_reached_the_goal?
        }

        transition online: :waiting_funds,        if: ->(project) {
          project.expired? && (project.pending_contributions_reached_the_goal? || project.flexible?)
        }

        transition waiting_funds: :successful,    if: ->(project) {
          (project.reached_goal? || project.flexible?) && !project.in_time_to_wait?
        }

        transition waiting_funds: :failed,        if: ->(project) {
          !project.flexible? && project.expired? && !project.reached_goal? && !project.in_time_to_wait?
        }

        transition waiting_funds: :waiting_funds, if: ->(project) {
          project.expired? && !project.reached_goal? && (project.in_time_to_wait?)
        }
      end

      after_transition do |project, transition|
        project.notify_observers :"from_#{transition.from}_to_#{transition.to}"
      end

      after_transition any => [:failed, :successful] do |project, transition|
        project.notify_observers :sync_with_mailchimp
      end

      after_transition [:draft, :rejected] => :deleted do |project, transition|
        project.update_attributes({ permalink: "deleted_project_#{project.id}"})
      end
    end
  end
end


{'fraction_non_alphanumeric': 0.10123506782749545, 'fraction_numerical': 0.0, 'mean_word_length': 2.531093638313081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4435919', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1455, 'n_words': 367}