<commit_before>class ContentOnlyController < ApplicationController
  before_action :authenticate_user!,
                :check_account_completion,
                except: [
                  :home,
                  :awards_for_organisations,
                  :enterprise_promotion_awards,
                  :how_to_apply,
                  :timeline,
                  :additional_information_and_contact,
                  :privacy,
                  :cookies,
                  :apply_for_queens_award_for_enterprise,
                  :sign_up_complete,
                  :submitted_nomination_successful
                ]

  before_action :get_current_form,
                only: [
                  :award_info_innovation,
                  :award_info_trade,
                  :award_info_development,
                  :award_info_promotion
                ]

  before_action :get_collaborators,
                only: [
                  :award_info_innovation,
                  :award_info_trade,
                  :award_info_development,
                  :award_info_promotion
                ]

  before_action :restrict_access_if_admin_in_read_only_mode!,
                only: [:dashboard]

  before_action :clean_flash, only: [:sign_up_complete]

  expose(:form_answer) {
    current_user.form_answers.find(params[:id])
  }

  expose(:past_applications) {
    current_account.form_answers.submitted.past.group_by(&:award_year)
  }

  def dashboard
    @user_award_forms = user_award_forms

    forms = @user_award_forms.group_by(&:award_type)

    @user_award_forms_trade = forms["trade"]
    @user_award_forms_innovation = forms["innovation"]
    @user_award_forms_development = forms["development"]
    @user_award_forms_promotion = forms["promotion"]

    @user_award_forms_submitted = @user_award_forms.where(submitted: true)

    set_unsuccessful_business_applications if Settings.unsuccessful_stage?
  end

  def award_winners_section
    @user_award_forms_submitted = user_award_forms.submitted

    award_year = if params[:award_year_id].present?
      AwardYear.find(params[:award_year_id])
    else
      AwardYear.current
    end

    render "content_only/award_winners_section/#{award_year.year}"
  end

  private

  def user_award_forms
    current_account.form_answers
                   .where(award_year: AwardYear.current)
                   .order("award_type")
  end

  def get_current_form
    @form_answer = current_account.form_answers.find(params[:form_id])
    @form = @form_answer.award_form.decorate(
      answers: HashWithIndifferentAccess.new(@form_answer.document)
    )
  end

  def get_collaborators
    @collaborators = current_user.account.collaborators_without(current_user)
  end
<commit_msg>[Past Applications] small CodeClimate fixes<commit_after>class ContentOnlyController < ApplicationController
  before_action :authenticate_user!,
                :check_account_completion,
                except: [
                  :home,
                  :awards_for_organisations,
                  :enterprise_promotion_awards,
                  :how_to_apply,
                  :timeline,
                  :additional_information_and_contact,
                  :privacy,
                  :cookies,
                  :apply_for_queens_award_for_enterprise,
                  :sign_up_complete,
                  :submitted_nomination_successful
                ]

  before_action :get_current_form,
                only: [
                  :award_info_innovation,
                  :award_info_trade,
                  :award_info_development,
                  :award_info_promotion
                ]

  before_action :get_collaborators,
                only: [
                  :award_info_innovation,
                  :award_info_trade,
                  :award_info_development,
                  :award_info_promotion
                ]

  before_action :restrict_access_if_admin_in_read_only_mode!,
                only: [:dashboard]

  before_action :clean_flash, only: [:sign_up_complete]

  expose(:form_answer) do
    current_user.form_answers.find(params[:id])
  end

  expose(:past_applications) do
    current_account.form_answers.submitted.past.group_by(&:award_year)
  end

  expose(:winners_award_year) do
    if params[:award_year_id].present?
      AwardYear.find(params[:award_year_id])
    else
      AwardYear.current
    end
  end

  def dashboard
    @user_award_forms = user_award_forms

    forms = @user_award_forms.group_by(&:award_type)

    @user_award_forms_trade = forms["trade"]
    @user_award_forms_innovation = forms["innovation"]
    @user_award_forms_development = forms["development"]
    @user_award_forms_promotion = forms["promotion"]

    @user_award_forms_submitted = @user_award_forms.where(submitted: true)

    set_unsuccessful_business_applications if Settings.unsuccessful_stage?
  end

  def award_winners_section
    @user_award_forms_submitted = user_award_forms.submitted

    render "content_only/award_winners_section/#{winners_award_year.year}"
  end

  private

  def user_award_forms
    current_account.form_answers
                   .where(award_year: AwardYear.current)
                   .order("award_type")
  end

  def get_current_form
    @form_answer = current_account.form_answers.find(params[:form_id])
    @form = @form_answer.award_form.decorate(
      answers: HashWithIndifferentAccess.new(@form_answer.document)
    )
  end

  def get_collaborators
    @collaborators = current_user.account.collaborators_without(current_user)
  end

{'fraction_non_alphanumeric': 0.0719165767709457, 'fraction_numerical': 0.0, 'mean_word_length': 2.3838199513381997, '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': '662043', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1662, 'n_words': 212}