<commit_before>class ReportsController < ApplicationController
  before_action :set_report, only: [:edit, :update]

  respond_to :html

  def index
    @reports = Report.includes(:event)
                     .order('events.datetime DESC')
                     .page(params[:page])
  end

  def no_content
    @reports = Report.no_content
                     .includes(:event)
                     .order('events.datetime DESC')
                     .page(params[:page])
  end

  def missing
    @events_without_report = Event.past.without_report.page(params[:page])
  end

  def show
    @event = Event.friendly.find(params[:event_id])
    @report = @event.report

    if @report.nil?
      redirect_to :back, alert: 'Spielbericht nicht vorhanden!' and return
    end
  end

  def new
    @report = Report.new(event_id: params[:event_id])
  end

  def create
    @report = Report.new(report_params)
    flash[:notice] = 'Bericht wurde erfolgreich erstellt.' if @report.save

    respond_with @report, location: reports_path
  end

  def edit
  end

  def update
    if @report.update(report_params)
      flash[:notice] = 'Bericht wurde erfolgreich aktualisiert.'
    end

    respond_with @report
  end

  private

  def set_report
    @report = Report.find(params[:id])<commit_msg>let admins create a missing Report <commit_after>class ReportsController < ApplicationController
  before_action :set_report, only: [:edit, :update]

  respond_to :html

  def index
    @reports = Report.includes(:event)
                     .order('events.datetime DESC')
                     .page(params[:page])
  end

  def no_content
    @reports = Report.no_content
                     .includes(:event)
                     .order('events.datetime DESC')
                     .page(params[:page])
  end

  def missing
    @events_without_report = Event.past.without_report.page(params[:page])
  end

  def show
    @event = Event.friendly.find(params[:event_id])
    @report = @event.report

    if @report.nil? && current_user.admin?
      redirect_to new_report_path(event_id: @event.id)
    elsif @report.nil?
      redirect_to :back, alert: 'Spielbericht nicht vorhanden!' and return
    end
  end

  def new
    @report = Report.new(event_id: params[:event_id])
  end

  def create
    @report = Report.new(report_params)
    flash[:notice] = 'Bericht wurde erfolgreich erstellt.' if @report.save

    respond_with @report, location: reports_path
  end

  def edit
  end

  def update
    if @report.update(report_params)
      flash[:notice] = 'Bericht wurde erfolgreich aktualisiert.'
    end

    respond_with @report
  end

  private

  def set_report
    @report = Report.find(params[:id])
{'fraction_non_alphanumeric': 0.09959123002601264, 'fraction_numerical': 0.0, 'mean_word_length': 2.6329284750337383, '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': '655037', 'n_tokens_mistral': 843, 'n_tokens_neox': 808, 'n_words': 197}