<commit_before>class EventsController < ApplicationController
  include ActionController::MimeResponds

  before_action :set_event, only: [:show,
                                   :edit,
                                   :update,
                                   :destroy,
                                   :open,
                                   :close,
                                   :open_with_mail,
                                   :open_replies_mail,
                                   :close_with_mail,
                                   :close_replies_mail]

  before_action :authorize_admin!, except: [:index, :show]

  respond_to :html

  def index
    @events = Event.order('datetime DESC').page(params[:page])
  end

  def show
    @reply = Reply.find_or_initialize_by(event_id: @event.id,
                                         user_id: current_user.id)

    respond_to do |format|
      format.html
      format.ics do
        calendar = Icalendar::Calendar.new
        calendar.add_event(@event.to_ics)
        calendar.publish
        render text: calendar.to_ical
      end
    end
  end

  def new
    @event = Event.new(type: params[:type])

    respond_with(@event)
  end

  def edit
  end

  def create
    @event = Event.new(event_params)
    @event.save

    respond_with(@event)
  end

  def update
    @event.update(event_params)

    respond_with(@event)
  end

  def destroy
    @event.destroy

    respond_with(@event, location: events_path)
  end

  def open
    if @event.open!
      flash[:notice] = 'Meldeliste wurde erfolgreich geöffnet.'
    else
      flash[:alert] = 'Meldeliste konnte nicht geöffnet werden.'
    end

    redirect_to :back
  end

  def open_replies_mail
    @all_users = User.includes(:user_profile).order(:username)

    @possible_user_ids = @event
                         .possible_players
                         .includes(:user_profile)
                         .pluck(:id)
  end
<commit_msg>fix redirection after updating event<commit_after>class EventsController < ApplicationController
  include ActionController::MimeResponds

  before_action :set_event, only: [:show,
                                   :edit,
                                   :update,
                                   :destroy,
                                   :open,
                                   :close,
                                   :open_with_mail,
                                   :open_replies_mail,
                                   :close_with_mail,
                                   :close_replies_mail]

  before_action :authorize_admin!, except: [:index, :show]

  respond_to :html

  def index
    @events = Event.order('datetime DESC').page(params[:page])
  end

  def show
    @reply = Reply.find_or_initialize_by(event_id: @event.id,
                                         user_id: current_user.id)

    respond_to do |format|
      format.html
      format.ics do
        calendar = Icalendar::Calendar.new
        calendar.add_event(@event.to_ics)
        calendar.publish
        render text: calendar.to_ical
      end
    end
  end

  def new
    @event = Event.new(type: params[:type])

    respond_with(@event)
  end

  def edit
  end

  def create
    @event = Event.new(event_params)
    @event.save

    respond_with(@event)
  end

  def update
    @event.update(event_params)

    respond_with(@event, location: event_path(@event))
  end

  def destroy
    @event.destroy

    respond_with(@event, location: events_path)
  end

  def open
    if @event.open!
      flash[:notice] = 'Meldeliste wurde erfolgreich geöffnet.'
    else
      flash[:alert] = 'Meldeliste konnte nicht geöffnet werden.'
    end

    redirect_to :back
  end

  def open_replies_mail
    @all_users = User.includes(:user_profile).order(:username)

    @possible_user_ids = @event
                         .possible_players
                         .includes(:user_profile)
                         .pluck(:id)
  end

{'fraction_non_alphanumeric': 0.0795483061480552, 'fraction_numerical': 0.0, 'mean_word_length': 1.543714103382259, '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': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4874507', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1085, 'n_words': 232}