<commit_before>apply File.expand_path("../rails_template.rb", __FILE__)

inject_into_file 'config/initializers/active_admin.rb', <<-RUBY, after: "ActiveAdmin.setup do |config|\n"

  config.comments_menu = { parent: 'Administrative' }
RUBY

inject_into_file 'app/admin/admin_user.rb', <<-RUBY, after: "ActiveAdmin.register AdminUser do\n"

  menu parent: "Administrative", priority: 1
RUBY

%w{Post User Category Tag}.each do |type|
  generate :'active_admin:resource', type
end

inject_into_file 'app/admin/category.rb', <<-RUBY, after: "ActiveAdmin.register Category do\n"

  config.create_another = true

  permit_params [:name, :description]
RUBY

inject_into_file 'app/admin/user.rb', <<-RUBY, after: "ActiveAdmin.register User do\n"

  config.create_another = true

  permit_params [:first_name, :last_name, :username, :age]

  show do
    attributes_table do
      row :id
      row :first_name
      row :last_name
      row :username
      row :age
      row :created_at
      row :updated_at
    end

    panel 'Posts' do
      table_for(user.posts.order(:updated_at).limit(10)) do
        column :id do |post|
          link_to post.id, admin_post_path(post)
        end
        column :title
        column :published_date
        column :category
        column :created_at
        column :updated_at
      end
      para do
        link_to "View all posts", admin_posts_path('q[author_id_eq]' => user.id)
      end
    end
  end
RUBY

inject_into_file 'app/admin/post.rb', <<-RUBY, after: "ActiveAdmin.register Post do\n"

  permit_params :custom_category_id, :author_id, :title, :body, :published_date, :position, :starred, taggings_attributes: [ :id, :tag_id, :name, :position, :_destroy ]<commit_msg>Eager load data to avoid n+1 queries and minimize log noise<commit_after>apply File.expand_path("../rails_template.rb", __FILE__)

inject_into_file 'config/initializers/active_admin.rb', <<-RUBY, after: "ActiveAdmin.setup do |config|\n"

  config.comments_menu = { parent: 'Administrative' }
RUBY

inject_into_file 'app/admin/admin_user.rb', <<-RUBY, after: "ActiveAdmin.register AdminUser do\n"

  menu parent: "Administrative", priority: 1
RUBY

%w{Post User Category Tag}.each do |type|
  generate :'active_admin:resource', type
end

inject_into_file 'app/admin/category.rb', <<-RUBY, after: "ActiveAdmin.register Category do\n"

  config.create_another = true

  permit_params [:name, :description]
RUBY

inject_into_file 'app/admin/user.rb', <<-RUBY, after: "ActiveAdmin.register User do\n"

  config.create_another = true

  permit_params [:first_name, :last_name, :username, :age]

  show do
    attributes_table do
      row :id
      row :first_name
      row :last_name
      row :username
      row :age
      row :created_at
      row :updated_at
    end

    panel 'Posts' do
      table_for(user.posts.includes(:category).order(:updated_at).limit(10)) do
        column :id do |post|
          link_to post.id, admin_post_path(post)
        end
        column :title
        column :published_date
        column :category
        column :created_at
        column :updated_at
      end
      para do
        link_to "View all posts", admin_posts_path('q[author_id_eq]' => user.id)
      end
    end
  end
RUBY

inject_into_file 'app/admin/post.rb', <<-RUBY, after: "ActiveAdmin.register Post do\n"

  permit_params :custom_category_id, :author_id, :title, :body, :published_date, :position, :starred, taggings_attributes: [ :id, :tag_id, :name, :position, :_destroy ]

  includes :author, :category, :taggings
{'fraction_non_alphanumeric': 0.11581920903954802, 'fraction_numerical': 0.0019774011299435027, 'mean_word_length': 3.5223499361430397, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 5, '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': '1355451', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1170, 'n_words': 294}