<commit_before>class PeopleController < ApplicationController
  before_filter :authenticate_user!
  before_filter :get_person, :except => [:index]
  before_filter :only_if_person_is_signed_in!, :only => [:edit, :update]
  before_filter :only_own_network!, :only => [:my_network]

  def index
  
    @people = current_user.person.trusted_friends
    
    respond_to do |format|
      format.html { render :action => 'search' if params[:search] }
      format.xml  { render :xml => @people }
    end
  end

  def show
    if @person.belongs_to? current_user
      if params[:filter_type].nil?
        @items = @person.items.without_deleted
      else
        @items = @person.items.without_deleted.with_type(params[:filter_type])
      end
      @unanswered_requests = @person.unanswered_requests
    else
      if params[:filter_type].nil?
        @items = @person.items.without_deleted.visible_to_other_users
      else
        @items = @person.items.without_deleted.visible_to_other_users.with_type(params[:filter_type])
      end
      @unanswered_requests = @person.unanswered_requests(current_user.person)
    end

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @item }
    end
  end
  
  def network
    @other, @mutual_friends, @trusted_network, @extended_network = [], [], [], []
    current_person = current_user.person
    unless params[:type].nil?
      case params[:type]
          when 'mutual'
            @mutual_friends = @person.mutural_friends(current_user.person) 
          when 'extended'
            #
          when 'other'
            mutual_friends = @person.mutural_friends(current_user.person)
            trusted_network = @person.trusted_friends
            @other = trusted_network - mutual_friends
            @other.delete_at(@other.index(current_person) || @other.length) unless @person.belongs_to? current_user
          else
            #
      end
    else       
      @trusted_network = @person.trusted_friends
      @mutual_friends = @person.mutural_friends(current_user.person)
      @other = @trusted_network - @mutual_friends
      @other.delete_at(@other.index(current_person) || @other.length) unless @person.belongs_to? current_user
    end
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @item }
    end
  end
  
  def my_network
    case params[:type]
      when 'trusted'
        @items = @person.trusted_friends_items(params[:filter_type])
      else
        @items = @person.trusted_friends_items(params[:filter_type])<commit_msg>Order items properly by item type<commit_after>class PeopleController < ApplicationController
  before_filter :authenticate_user!
  before_filter :get_person, :except => [:index]
  before_filter :only_if_person_is_signed_in!, :only => [:edit, :update]
  before_filter :only_own_network!, :only => [:my_network]

  def index
  
    @people = current_user.person.trusted_friends
    
    respond_to do |format|
      format.html { render :action => 'search' if params[:search] }
      format.xml  { render :xml => @people }
    end
  end

  def show
    if @person.belongs_to? current_user
      if params[:filter_type].nil?
        @items = @person.items.without_deleted.sort_by{|i| i.item_type.downcase}
      else
        @items = @person.items.without_deleted.with_type(params[:filter_type])
      end
      @unanswered_requests = @person.unanswered_requests
    else
      if params[:filter_type].nil?
        @items = @person.items.without_deleted.visible_to_other_users.sort_by{|i| i.item_type.downcase}
      else
        @items = @person.items.without_deleted.visible_to_other_users.with_type(params[:filter_type])
      end
      @unanswered_requests = @person.unanswered_requests(current_user.person)
    end

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @item }
    end
  end
  
  def network
    @other, @mutual_friends, @trusted_network, @extended_network = [], [], [], []
    current_person = current_user.person
    unless params[:type].nil?
      case params[:type]
          when 'mutual'
            @mutual_friends = @person.mutural_friends(current_user.person) 
          when 'extended'
            #
          when 'other'
            mutual_friends = @person.mutural_friends(current_user.person)
            trusted_network = @person.trusted_friends
            @other = trusted_network - mutual_friends
            @other.delete_at(@other.index(current_person) || @other.length) unless @person.belongs_to? current_user
          else
            #
      end
    else       
      @trusted_network = @person.trusted_friends
      @mutual_friends = @person.mutural_friends(current_user.person)
      @other = @trusted_network - @mutual_friends
      @other.delete_at(@other.index(current_person) || @other.length) unless @person.belongs_to? current_user
    end
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @item }
    end
  end
  
  def my_network
    case params[:type]
      when 'trusted'
        @items = @person.trusted_friends_items(params[:filter_type]).sort_by{|i| i.item_type.downcase}
      else
        @items = @person.trusted_friends_items(params[:filter_type]).sort_by{|i| i.item_type.downcase}
{'fraction_non_alphanumeric': 0.10587792012057272, 'fraction_numerical': 0.0, 'mean_word_length': 2.9560357675111772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '2870579', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1645, 'n_words': 298}