<commit_before>class PeopleController < ApplicationController
  before_action :set_person, only: [:show]

  etag { can? :manage, Entity } # Don't cache admin content together with the rest

  # GET /people
  # GET /people.json
  def index
    @title = 'Osoby'
    @people = (can? :manage, Entity) ? Entity.people : Entity.people.published
    if stale?(last_modified: @people.maximum(:updated_at), :public => current_user.nil?)
      #@people = @people.order("updated_at DESC").page(params[:page]).per(12)

      @people = @people.joins(:relations_as_target)
                .select('entities.*, count(relations.id) as relations_count')
                .group('entities.id')
                .order('relations_count DESC')
                .page(params[:page]).per(12)
    end
  end

  # GET /people/1
  # GET /people/1.json
  def show
    authorize! :read, @person
    if stale?(@person, :public => current_user.nil?)
      @title = @person.short_or_long_name
      @relations = []
      if(can? :manage, Entity)
        @person.relations
      else
        @person.relations.published.map{|e| if e.target.published && e.source.published then @relations.push e end}
      end

      embed_url = url_for controller: 'relation_visualizations', action: 'show', id: @person.slug
      @embed = "<iframe width='600' height='475' src='#{embed_url}'></iframe>"
<commit_msg>relations_as_source<commit_after>class PeopleController < ApplicationController
  before_action :set_person, only: [:show]

  etag { can? :manage, Entity } # Don't cache admin content together with the rest

  # GET /people
  # GET /people.json
  def index
    @title = 'Osoby'
    @people = (can? :manage, Entity) ? Entity.people : Entity.people.published
    if stale?(last_modified: @people.maximum(:updated_at), :public => current_user.nil?)
      #@people = @people.order("updated_at DESC").page(params[:page]).per(12)

      @people = @people.joins(:relations_as_source)
                .select('entities.*, count(relations.id) as relations_count')
                .group('entities.id')
                .order('relations_count DESC')
                .page(params[:page]).per(12)
    end
  end

  # GET /people/1
  # GET /people/1.json
  def show
    authorize! :read, @person
    if stale?(@person, :public => current_user.nil?)
      @title = @person.short_or_long_name
      @relations = []
      if(can? :manage, Entity)
        @person.relations
      else
        @person.relations.published.map{|e| if e.target.published && e.source.published then @relations.push e end}
      end

      embed_url = url_for controller: 'relation_visualizations', action: 'show', id: @person.slug
      @embed = "<iframe width='600' height='475' src='#{embed_url}'></iframe>"

{'fraction_non_alphanumeric': 0.14181286549707603, 'fraction_numerical': 0.008771929824561403, 'mean_word_length': 3.0548148148148146, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5268957', 'n_tokens_mistral': 894, 'n_tokens_neox': 836, 'n_words': 192}