<commit_before>class WelcomeController < ApplicationController

  before_action :require_user, only: [:index]
  layout false, only: [:landing]

  def index
    if current_user_session
      team_follower_ids = []
      tournament_follower_ids = []
      game_follower_ids = []
      league_follower_ids = []
      current_user.all_following.each do |f|
        if f.class.to_s == "Game"
          game_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "Team"
          team_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "Tournament"
          tournament_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "League"
          league_follower_ids  <<  f.id.to_s
        end
      end
      @team_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Team' AND announcable_id IN (" + team_follower_ids.join(",")+")")
      @tournament_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Tournament' AND announcable_id IN (" + tournament_follower_ids.join(",")+")")
      @league_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'League' AND announcable_id IN (" + league_follower_ids.join(",")+")")
      @game_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Game' AND announcable_id IN (" +game_follower_ids.join(",")+")")
      @announces = Announce.joins(:announcement_viewed).where("(viewed = 'false' AND announcable_type = 'Game' AND announcable_id IN (" + game_follower_ids.join(",")+")) OR (viewed = 'false' AND announcable_type = 'Team' AND announcable_id IN (" + team_follower_ids.join(",")+")) OR (viewed = 'false' AND announcable_type = 'Tournament' AND announcable_id IN (" + tournament_follower_ids.join(",") + ")) OR (viewed = 'false' AND announcable_type = 'League' AND announcable_id IN (" + league_follower_ids.join(",")+"))").page(params['page']).per(5)
      respond_to do |format|
        format.json{
          render json: @announces, serializer: AnnounceSerializer
        }
        format.html{

        }
      end
    else
      @announces = []
    end

    def landing

    end
  end

end<commit_msg>fixed query on main index<commit_after>class WelcomeController < ApplicationController

  before_action :require_user, only: [:index]
  layout false, only: [:landing]

  def index
    if current_user_session
      team_follower_ids = []
      tournament_follower_ids = []
      game_follower_ids = []
      league_follower_ids = []
      current_user.all_following.each do |f|
        if f.class.to_s == "Game"
          game_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "Team"
          team_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "Tournament"
          tournament_follower_ids <<  f.id.to_s
        elsif f.class.to_s == "League"
          league_follower_ids  <<  f.id.to_s
        end
      end
      @team_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Team' AND announcable_id IN (" + team_follower_ids.join(",")+")")
      @tournament_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Tournament' AND announcable_id IN (" + tournament_follower_ids.join(",")+")")
      @league_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'League' AND announcable_id IN (" + league_follower_ids.join(",")+")")
      @game_announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Game' AND announcable_id IN (" +game_follower_ids.join(",")+")")
      @announces = Announce.joins(:announcement_viewed).where("viewed = 'false' AND announcable_type = 'Game' AND announcable_id IN (" + game_follower_ids.join(",")+") OR viewed = 'false' AND announcable_type = 'Team' AND announcable_id IN (" + team_follower_ids.join(",")+") OR viewed = 'false' AND announcable_type = 'Tournament' AND announcable_id IN (" + tournament_follower_ids.join(",") + ") OR viewed = 'false' AND announcable_type = 'League' AND announcable_id IN (" + league_follower_ids.join(",")+")").page(params['page']).per(5)
      respond_to do |format|
        format.json{
          render json: @announces, serializer: AnnounceSerializer
        }
        format.html{

        }
      end
    else
      @announces = []
    end

    def landing

    end
  end

end
{'fraction_non_alphanumeric': 0.13434841021047916, 'fraction_numerical': 0.0004478280340349306, 'mean_word_length': 3.572159672466735, 'pattern_counts': {'":': 0, '<': 21, '<?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': '7470543', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1504, 'n_words': 289}