<commit_before>class Legislation::ProcessesController < Legislation::BaseController
  has_filters %w{open next past}, only: :index
  load_and_authorize_resource

  def index
    @current_filter ||= 'open'
    @processes = ::Legislation::Process.send(@current_filter).page(params[:page])
  end

  def show
    if process.allegations_phase.enabled? && process.allegations_phase.started? && draft_version = process.draft_versions.published.last
      redirect_to legislation_process_draft_version_path(process, draft_version)
    elsif process.debate_phase.enabled?
      redirect_to legislation_process_debate_path(process)
    else
      redirect_to legislation_process_allegations_path(process)
    end
  end

  def debate
    if process.debate_phase.started?
      render :debate
    else
      render :phase_not_open
    end
  end

  def draft_publication
    if process.draft_publication.started?
      if draft_version = process.draft_versions.published.last
        redirect_to legislation_process_draft_version_path(process, draft_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  def allegations
    if process.allegations_phase.started?
      if draft_version = process.draft_versions.published.last
        redirect_to legislation_process_draft_version_path(process, draft_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  def result_publication
    if process.result_publication.started?
      if final_version = process.final_draft_version
        redirect_to legislation_process_draft_version_path(process, final_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  private

    def process
      @process ||= ::Legislation::Process.find(params[:process_id])
    end
end<commit_msg>Fix Legislation Process Controller to correctly set both @phase and @process<commit_after>class Legislation::ProcessesController < Legislation::BaseController
  has_filters %w{open next past}, only: :index
  load_and_authorize_resource

  def index
    @current_filter ||= 'open'
    @processes = ::Legislation::Process.send(@current_filter).page(params[:page])
  end

  def show
    if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version = @process.draft_versions.published.last
      redirect_to legislation_process_draft_version_path(@process, draft_version)
    elsif @process.debate_phase.enabled?
      redirect_to legislation_process_debate_path(@process)
    else
      redirect_to legislation_process_allegations_path(@process)
    end
  end

  def debate
    set_process
    @phase = :debate_phase

    if @process.debate_phase.started?
      render :debate
    else
      render :phase_not_open
    end
  end

  def draft_publication
    set_process
    @phase = :draft_publication

    if @process.draft_publication.started?
      if draft_version = @process.draft_versions.published.last
        redirect_to legislation_process_draft_version_path(@process, draft_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  def allegations
    set_process
    @phase = :allegations_phase

    if @process.allegations_phase.started?
      if draft_version = @process.draft_versions.published.last
        redirect_to legislation_process_draft_version_path(@process, draft_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  def result_publication
    set_process
    @phase = :result_publication

    if @process.result_publication.started?
      if final_version = @process.final_draft_version
        redirect_to legislation_process_draft_version_path(@process, final_version)
      else
        render :phase_empty
      end
    else
      render :phase_not_open
    end
  end

  private

    def set_process
      @process = ::Legislation::Process.find(params[:process_id])
    end
end
{'fraction_non_alphanumeric': 0.06321269211700545, 'fraction_numerical': 0.0, 'mean_word_length': 3.458563535911602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2762037', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1158, 'n_words': 243}