<commit_before>ActiveAdmin.register Donation do

# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
#   permitted = [:permitted, :attributes]
#   permitted << :other if params[:action] == 'create' && current_user.admin?
#   permitted
# end
  config.batch_actions = false

  scope :all, default: true
  if DonationStatus.first
    DonationStatus.order(id: :asc).each do |s|
      scope(s.name) { |scope| scope.where("donations.status_id=?", s.id) }
    end
  end

  index do
    column("ID", :sortable => :id) {|d| link_to "#{d.id}", admin_donation_path(d) }
    column("Status")               {|d| status_tag(d.status.name) } if DonationStatus.first
    column("Recipient")            {|d| link_to d.recipient.name, admin_recipient_path(d.recipient) }
    column("Donor")                {|d| link_to d.donor.name, admin_user_path(d.donor) }
    column("Driver")               {|d| link_to d.driver.name, admin_user_path(d.driver) }
    column "Initiated", :created_at
    column "Updated", :updated_at
    actions
  end

  permit_params :donor_id, :driver_id, :recipient_id, :status_id

end<commit_msg>Fix: add a database check in donation.rb when it loads the DonationStatus<commit_after>ActiveAdmin.register Donation do

# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
#   permitted = [:permitted, :attributes]
#   permitted << :other if params[:action] == 'create' && current_user.admin?
#   permitted
# end
  config.batch_actions = false

  scope :all, default: true
  if database_exists?
    DonationStatus.order(id: :asc).each do |s|
      scope(s.name) { |scope| scope.where("donations.status_id=?", s.id) }
    end
  end

  index do
    column("ID", :sortable => :id) {|d| link_to "#{d.id}", admin_donation_path(d) }
    column("Status")               {|d| status_tag(d.status.name) } if database_exists?
    column("Recipient")            {|d| link_to d.recipient.name, admin_recipient_path(d.recipient) }
    column("Donor")                {|d| link_to d.donor.name, admin_user_path(d.donor) }
    column("Driver")               {|d| link_to d.driver.name, admin_user_path(d.driver) }
    column "Initiated", :created_at
    column "Updated", :updated_at
    actions
  end

  def database_exists?
    ActiveRecord::Base.connection
  rescue ActiveRecord::NoDatabaseError
    false
  else
    true
  end

  permit_params :donor_id, :driver_id, :recipient_id, :status_id

end
{'fraction_non_alphanumeric': 0.13713460844460484, 'fraction_numerical': 0.0007217610970768675, 'mean_word_length': 3.6666666666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3178890', 'n_tokens_mistral': 951, 'n_tokens_neox': 929, 'n_words': 197}