<commit_before>class MainController < ApplicationController
  def home
    @surveys = Survey.available_to_complete
    respond_to do |format|
      format.html { render '/home/index' }
    end
  end

  def comment
    @topic = params[:topic]
    @title = params[:title] || @topic
    @back  = params[:back]

    # Look for a question with this topic and use the help text
    @topic_help = begin
      Question.find(params[:question_id]).help_text
    rescue ActiveRecord::RecordNotFound
      ''
    end
  end

  def discussion
    @topic = 'general'
    @topic_help  = I18n.t 'general', scope: :discussions, default: ''
    render 'comment'
  end

  def status
    @job_count = Delayed::Job.count

    @counts = {
      'certificates' => Certificate.counts,
      'datasets'     => ResponseSet.counts
    }

    @head_commit = `git rev-parse HEAD`

    render '/home/status'
  end

  def status_csv
    csv = Rackspace.fetch_cache("statistics.csv")
    render text: csv, content_type: "text/csv"
  end

  def status_response_sets
    @response_sets = ResponseSet.all.map do |m|
      {
        id: m.id,
        created_at: m.created_at.to_i,
        state: m.aasm_state
      }<commit_msg>Get head commit from Rails root rather than git<commit_after>class MainController < ApplicationController
  def home
    @surveys = Survey.available_to_complete
    respond_to do |format|
      format.html { render '/home/index' }
    end
  end

  def comment
    @topic = params[:topic]
    @title = params[:title] || @topic
    @back  = params[:back]

    # Look for a question with this topic and use the help text
    @topic_help = begin
      Question.find(params[:question_id]).help_text
    rescue ActiveRecord::RecordNotFound
      ''
    end
  end

  def discussion
    @topic = 'general'
    @topic_help  = I18n.t 'general', scope: :discussions, default: ''
    render 'comment'
  end

  def status
    @job_count = Delayed::Job.count

    @counts = {
      'certificates' => Certificate.counts,
      'datasets'     => ResponseSet.counts
    }

    @head_commit = Rails.root.to_s.split("/").last

    render '/home/status'
  end

  def status_csv
    csv = Rackspace.fetch_cache("statistics.csv")
    render text: csv, content_type: "text/csv"
  end

  def status_response_sets
    @response_sets = ResponseSet.all.map do |m|
      {
        id: m.id,
        created_at: m.created_at.to_i,
        state: m.aasm_state
      }
{'fraction_non_alphanumeric': 0.1053931659118979, 'fraction_numerical': 0.0016467682173734047, 'mean_word_length': 2.654135338345865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7639639', 'n_tokens_mistral': 807, 'n_tokens_neox': 774, 'n_words': 194}