<commit_before>require 'active_admin/views'
require 'active_admin/views/components/panel'

module ActiveAdmin
  module Comments
    module Views

      class Comments < ActiveAdmin::Views::Panel
        builder_method :active_admin_comments_for

        attr_accessor :resource

        def build(resource)
          @resource = resource
          @comments = ActiveAdmin::Comment.find_for_resource_in_namespace(resource, active_admin_namespace.name).page(params[:page])
          super(title, for: resource)
          build_comments
        end

        protected

        def title
          I18n.t 'active_admin.comments.title_content', count: @comments.total_count
        end

        def build_comments
          @comments.any? ? @comments.each(&method(:build_comment)) : build_empty_message
          div page_entries_info(@comments).html_safe, class: 'pagination_information'
          text_node paginate @comments
          build_comment_form
        end

        def build_comment(comment)
          div for: comment do
            div class: 'active_admin_comment_meta' do
              h4 class: 'active_admin_comment_author' do
                comment.author ? auto_link(comment.author) : I18n.t('active_admin.comments.author_missing')
              end
              span pretty_format comment.created_at
              if authorized?(ActiveAdmin::Auth::DESTROY, comment)
                text_node link_to I18n.t('active_admin.comments.delete'), comments_url(comment.id), method: :delete, data: { confirm: I18n.t('active_admin.comments.delete_confirmation') }
              end<commit_msg>Backport #5119: do not display pagination info when there are no comments<commit_after>require 'active_admin/views'
require 'active_admin/views/components/panel'

module ActiveAdmin
  module Comments
    module Views

      class Comments < ActiveAdmin::Views::Panel
        builder_method :active_admin_comments_for

        attr_accessor :resource

        def build(resource)
          @resource = resource
          @comments = ActiveAdmin::Comment.find_for_resource_in_namespace(resource, active_admin_namespace.name).page(params[:page])
          super(title, for: resource)
          build_comments
        end

        protected

        def title
          I18n.t 'active_admin.comments.title_content', count: @comments.total_count
        end

        def build_comments
          if @comments.any?
            @comments.each(&method(:build_comment))
            div page_entries_info(@comments).html_safe, class: 'pagination_information'
          else
            build_empty_message
          end

          text_node paginate @comments
          build_comment_form
        end

        def build_comment(comment)
          div for: comment do
            div class: 'active_admin_comment_meta' do
              h4 class: 'active_admin_comment_author' do
                comment.author ? auto_link(comment.author) : I18n.t('active_admin.comments.author_missing')
              end
              span pretty_format comment.created_at
              if authorized?(ActiveAdmin::Auth::DESTROY, comment)
                text_node link_to I18n.t('active_admin.comments.delete'), comments_url(comment.id), method: :delete, data: { confirm: I18n.t('active_admin.comments.delete_confirmation') }
              end
{'fraction_non_alphanumeric': 0.0777342573064176, 'fraction_numerical': 0.006628502561012353, 'mean_word_length': 2.5775862068965516, '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': '1091005', 'n_tokens_mistral': 897, 'n_tokens_neox': 865, 'n_words': 183}