<commit_before>class EventsController < ApplicationController
  load_and_authorize_resource except: [:create]

  def index
    if params[:search]
      filt = "event_name like ?"
      srch = "%#{params[:search]}%"
      @events = Event.where(filt,
    srch).order(:start_date).paginate(page: params[:page], per_page:
    25)
    else
      @events = Event.order(start_date: :desc).paginate(page: params[:page],
    per_page: 25)
    end
  end

  def create
    @event = Event.create(event_params)
    redirect_to @event
  end

  def update
    if @event.update(event_params)
      redirect_to @event
    else
      render 'edit'
    end
  end
  
  private
  def event_params
    params.require(:event).permit(:eventbrite_id, :event_name,<commit_msg>Clean up long code line in event controller<commit_after>class EventsController < ApplicationController
  load_and_authorize_resource except: [:create]

  def index
    if params[:search]
      filt = "event_name like ?"
      srch = "%#{params[:search]}%"
      pag = { page: params[:page], per_page: 25}
      @events = Event.where(filt, srch).order(:start_date).paginate(pag)
    else
      @events = Event.order(start_date: :desc).paginate(page: params[:page],
    per_page: 25)
    end
  end

  def create
    @event = Event.create(event_params)
    redirect_to @event
  end

  def update
    if @event.update(event_params)
      redirect_to @event
    else
      render 'edit'
    end
  end
  
  private
  def event_params
    params.require(:event).permit(:eventbrite_id, :event_name,
{'fraction_non_alphanumeric': 0.11096690460739779, 'fraction_numerical': 0.005191434133679429, 'mean_word_length': 3.2596685082872927, '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': '1776910', 'n_tokens_mistral': 520, 'n_tokens_neox': 500, 'n_words': 114}