<commit_before>class UsersController < ApplicationController
  def index
    redirect_to new_session_path(User)
  end

  def show
    @sidenav_expansion = 'community'

    @user    = User.find_by(user_params)
    return redirect_to(root_path, notice: 'That user does not exist.') if @user.nil?
    return redirect_to(root_path, notice: 'That user does not exist.') if @user.private_profile?

    @feed = ContentPageShare.where(user_id: @user.id)
      .order('created_at DESC')
      .includes([:content_page, :user, :share_comments])
      .limit(100)

    @content = @user.public_content.select { |type, list| list.any? }
    @tabs    = @content.keys
  
    @accent_color     = @user.favorite_page_type_color
    @accent_icon      = @user.favorite_page_type_icon
    @favorite_content = @user.favorite_page_type? ? @user.send(@user.favorite_page_type.downcase.pluralize).is_public : []

    # todo this is really bad and needs redone/improved
    # @stream  = @user.content_change_events.order('updated_at desc').limit(100).group_by do |cce|
    #   next if cce.content.nil?
    #   if cce.content.is_a?(Attribute)
    #     next if cce.content.entity.nil?
    #     cce.content.entity.id
    #   else
    #     cce.content.id
    #   end
    # end

    @stream = @user.recent_content_list(limit: 20)
    
    Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(@user.id, 'viewed profile', {<commit_msg>extra includes on profiles<commit_after>class UsersController < ApplicationController
  def index
    redirect_to new_session_path(User)
  end

  def show
    @sidenav_expansion = 'community'

    @user    = User.find_by(user_params)
    return redirect_to(root_path, notice: 'That user does not exist.') if @user.nil?
    return redirect_to(root_path, notice: 'That user does not exist.') if @user.private_profile?

    @feed = ContentPageShare.where(user_id: @user.id)
      .order('created_at DESC')
      .includes([:content_page, :secondary_content_page, :user, :share_comments])
      .limit(100)

    @content = @user.public_content.select { |type, list| list.any? }
    @tabs    = @content.keys
  
    @accent_color     = @user.favorite_page_type_color
    @accent_icon      = @user.favorite_page_type_icon
    @favorite_content = @user.favorite_page_type? ? @user.send(@user.favorite_page_type.downcase.pluralize).is_public : []
    @stream           = @user.recent_content_list(limit: 20)
    
    Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(@user.id, 'viewed profile', {
{'fraction_non_alphanumeric': 0.11827531645569621, 'fraction_numerical': 0.005142405063291139, 'mean_word_length': 3.5815217391304346, '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': '2958348', 'n_tokens_mistral': 873, 'n_tokens_neox': 848, 'n_words': 156}