<commit_before>class EventsController < ApplicationController

  def index
    # all events in feed
    @invited_events = current_user.invited_events
    # all events user is "in"
    @attending_invitations = current_user.invitations.where(status: "in")
    @attending_events = []
    @attending_invitations.each do |invite|
      @attending_events << Event.find(invite.event_id)
    end

    # all events user created
    @created_events = current_user.created_events

    respond_to do |format|
      format.html
      format.json { render :json => { :invited_events => @invited_events, :created_events => @created_events } }
    end
  end

  def new
    @event = current_user.created_events.new
  end

  def show
    @event = Event.find(params[:id])
    @invitations = @event.invitations

    respond_to do |format|
      format.html
      format.json { render :json => { :event => @event,
        :invitations => @invitations } }
    end
  end

  def create
    @event = current_user.created_events.create(event_params)
    redirect_to event_path(@event)
  end

  def update
    @event = Event.find(params[:id])
    @event.update(event_params)
    redirect_to event_path(@event)
  end

  def destroy
    @event = Event.find(params[:id])
    @event.destroy
    redirect_to events_path
  end

  private
<commit_msg>edited events controller to have actions that only return separate json objects for created,invited, and attending<commit_after>class EventsController < ApplicationController

  def index
    @invited_events = current_user.invited_events

    respond_to do |format|
      format.html
      format.json { render :json => { :invited_events => @invited_events, :created_events => @created_events } }
    end
  end

  def new
    @event = current_user.created_events.new
  end

  def show
    @event = Event.find(params[:id])
    @invitations = @event.invitations

    respond_to do |format|
      format.html
      format.json { render :json => { :event => @event,
        :invitations => @invitations } }
    end
  end

  def create
    @event = current_user.created_events.create(event_params)
    redirect_to event_path(@event)
  end

  def update
    @event = Event.find(params[:id])
    @event.update(event_params)
    redirect_to event_path(@event)
  end

  def destroy
    @event = Event.find(params[:id])
    @event.destroy
    redirect_to events_path
  end

  def attending
    @attending_invitations = current_user.invitations.where(status: "in")
    @attending_events = []
    @attending_invitations.each do |invite|
      @attending_events << Event.find(invite.event_id)

     respond_to do |format|
       format.html
       format.json { render :json => { :events => @events }}
     end
   end

   def created
     @events = current_user.created_events

     respond_to do |format|
       format.html
       format.json { render :json => { :events => @events }}
     end
   end
  private

{'fraction_non_alphanumeric': 0.09773662551440329, 'fraction_numerical': 0.0, 'mean_word_length': 3.091164095371669, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '1063887', 'n_tokens_mistral': 914, 'n_tokens_neox': 890, 'n_words': 213}