<commit_before>class NewsfeedController < ApplicationController

  # verifica se o user esta logado
  before_action :is_logged, except: [:index, :city]

  # verifica se a conta esta completa
  before_action :is_invited, except: [:index, :city]

  # verifica se a conta esta completa
  before_action :is_complete, except: [:index, :city]

  include Gmaps



  # Layout newsfeed
  layout "three-columns"


  def index

    if current_or_guest_user.nil?
      redirect_to welcome_path
    elsif current_or_guest_user.city_slug
      redirect_to newsfeed_city_path(current_or_guest_user.city_slug) and return
    else
      @city = City.find_by(name: current_or_guest_user.city_name)
      @events = Event.where(city_name: current_or_guest_user.city_name).upcoming.by_persona

      @number_of_events = @events.count
      @message_for_none_events = "Não há eventos no momento em #{@city.try(:name)}."
      @feedback = Feedback.new

      # user location
      gon.latitude = current_or_guest_user.latitude
      gon.longitude = current_or_guest_user.longitude

      # array with places for map navigator on sidebar
      gon.events_local_formatted = format_for_map_this(@events)

      render :index
    end

  end

  def city

    if current_or_guest_user.guest?
      render_newsfeed_for_guest_user
    else
      @city = City.find_by(slug: params[:city])
      @events = Event.where(city_name: @city.name).upcoming

      @number_of_events = @events.count
      @message_for_none_events = "Não há eventos no momento em #{@city.name}."
      @feedback = Feedback.new

      # user location
      gon.latitude = current_or_guest_user.latitude
      gon.longitude = current_or_guest_user.longitude

      # array with places for map navigator on sidebar
      gon.events_local_formatted = format_for_map_this(@events)

      render :index
    end

  end

  def neighborhood
    @city = City.find_by(slug: params[:city])
    @neighborhood = Neighborhood.find_by(slug: params[:neighborhood])
    @events = Event.where(city_name: @city.name, neighborhood_name: @neighborhood.name).upcoming
    @number_of_events = @events.count
    @message_for_none_events = "Não há eventos no momento em #{@neighborhood.name}."
    render :index<commit_msg>Created scope to order event by persona user<commit_after>class NewsfeedController < ApplicationController

  # verifica se o user esta logado
  before_action :is_logged, except: [:index, :city]

  # verifica se a conta esta completa
  before_action :is_invited, except: [:index, :city]

  # verifica se a conta esta completa
  before_action :is_complete, except: [:index, :city]

  include Gmaps



  # Layout newsfeed
  layout "three-columns"


  def index

    if current_or_guest_user.nil?
      redirect_to welcome_path
    elsif current_or_guest_user.city_slug
      redirect_to newsfeed_city_path(current_or_guest_user.city_slug) and return
    else
      @city = City.find_by(name: current_or_guest_user.city_name)
      @events = Event.where(city_name: current_or_guest_user.city_name).upcoming

      @number_of_events = @events.count
      @message_for_none_events = "Não há eventos no momento em #{@city.try(:name)}."
      @feedback = Feedback.new

      # user location
      gon.latitude = current_or_guest_user.latitude
      gon.longitude = current_or_guest_user.longitude

      # array with places for map navigator on sidebar
      gon.events_local_formatted = format_for_map_this(@events)

      render :index
    end

  end

  def city

    if current_or_guest_user.guest?
      render_newsfeed_for_guest_user
    else
      @city = City.find_by(slug: params[:city])
      @events = Event.where(city_name: @city.name).upcoming.by_persona

      @number_of_events = @events.count
      @message_for_none_events = "Não há eventos no momento em #{@city.name}."
      @feedback = Feedback.new

      # user location
      gon.latitude = current_or_guest_user.latitude
      gon.longitude = current_or_guest_user.longitude

      # array with places for map navigator on sidebar
      gon.events_local_formatted = format_for_map_this(@events)

      render :index
    end

  end

  def neighborhood
    @city = City.find_by(slug: params[:city])
    @neighborhood = Neighborhood.find_by(slug: params[:neighborhood])
    @events = Event.where(city_name: @city.name, neighborhood_name: @neighborhood.name).upcoming
    @number_of_events = @events.count
    @message_for_none_events = "Não há eventos no momento em #{@neighborhood.name}."
    render :index
{'fraction_non_alphanumeric': 0.08342578211670734, 'fraction_numerical': 0.0, 'mean_word_length': 3.6, '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': '7233752', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1463, 'n_words': 330}