<commit_before>ActiveAdmin.register Work do

  ## Permit these attributes to be updated
  permit_params :wks_gt_number, :wks_estc_number, :wks_coll_name, :wks_tcp_bibno, :wks_marc_record, :wks_eebo_citation_id, :wks_doc_directory,
                :wks_ecco_number, :wks_book_id, :wks_author, :wks_printer, :wks_word_count, :wks_title, :wks_eebo_image_id, :wks_eebo_url, :wks_pub_date,
                :wks_ecco_uncorrected_gale_ocr_path, :wks_corrected_xml_path, :wks_corrected_text_path, :wks_ecco_directory, :wks_ecco_gale_ocr_xml_path,
                :wks_organizational_unit, :wks_primary_print_font, :collection_id

  ## Controller customizations
  controller do
    skip_before_filter :get_dropdown_data
  end

  ## Index search filters
  filter :wks_work_id, label: 'ID'
  filter :collection
  filter :wks_gt_number
  filter :wks_estc_number
  filter :wks_ecco_number
  filter :wks_eebo_image_id

  ## INDEX
  index do
    column :id do |work|
      link_to work.id, admin_work_path(work)
    end
    column :collection
    column :wks_title
    column :wks_book_id
    column :wks_printer
    column :wks_gt_number
    actions
  end

  ## SHOW
  show do
    attributes_table do
      row :id
      row('Collection') do
        work.collection.name if work.collection.present?
      end
      row('GT Number') { |w| w.wks_gt_number }
      row('ESTC Number') { |w| w.wks_estc_number }
      row('Coll Name') { |w| w.wks_coll_name }
      row('TCP Bibno') { |w| w.wks_tcp_bibno }
      row('MARC Record') { |w| w.wks_marc_record }
      row('EEBO Citation ID') { |w| w.wks_eebo_citation_id }
      row('Doc Directory') { |w| w.wks_doc_directory }
      row('ECCO Number') { |w| w.wks_ecco_number }
      row('Book ID') { |w| w.wks_book_id }
      row('Author') { |w| w.wks_author }
      row('Printer') { |w| w.wks_printer }
      row('Word Count') { |w| w.wks_word_count }
      row('Title') { |w| w.wks_title }
      row('EEBO Image ID') { |w| w.wks_eebo_image_id }
      row('EEBO URL') { |w| w.wks_eebo_url }
      row('Pub Date') { |w| w.wks_pub_date }
      row('ECCO Uncorrected Gale OCR Path') { |w| w.wks_ecco_uncorrected_gale_ocr_path }
      row('Corrected XML Path') { |w| w.wks_corrected_xml_path }
      row('Corrected Text Path') { |w| w.wks_corrected_text_path }
      row('ECCO Directory') { |w| w.wks_ecco_directory }
      row('ECCO Gale OCR XML Path') { |w| w.wks_ecco_gale_ocr_xml_path }
      row('Organizational Unit') { |w| w.wks_organizational_unit }
      row('Primary Print Font') { |w| w.wks_primary_print_font } #TODO link to Admin PrintFont page
    end

    panel "Pages" do
      pages = work.pages
      paginated_collection(pages.page(params[:page]).per(15), download_links: false) do
        table_for collection do
          column :id do |p|
            link_to p.id, admin_page_path(p)
          end
          column :pg_ref_number
        end
      end
    end
  end

  ## NEW / EDIT
  form do |f|
    f.semantic_errors
    f.inputs do
      f.input :collection
      f.input :print_font
      f.input :wks_gt_number
      f.input :wks_estc_number
      f.input :wks_coll_name
      f.input :wks_tcp_bibno
      f.input :wks_marc_record
      f.input :wks_eebo_citation_id
      f.input :wks_doc_directory
      f.input :wks_ecco_number
      f.input :wks_book_id
      f.input :wks_author
      f.input :wks_printer
      f.input :wks_word_count
      f.input :wks_title
      f.input :wks_eebo_image_id
      f.input :wks_eebo_url
      f.input :wks_pub_date
      f.input :wks_ecco_uncorrected_gale_ocr_path
      f.input :wks_corrected_xml_path
      f.input :wks_corrected_text_path
      f.input :wks_ecco_directory
      f.input :wks_ecco_gale_ocr_xml_path
      f.input :wks_organizational_unit
    end
    f.actions
  end
end
<commit_msg>Update filters for works in admin interface<commit_after>ActiveAdmin.register Work do

  ## Permit these attributes to be updated
  permit_params :wks_gt_number, :wks_estc_number, :wks_coll_name, :wks_tcp_bibno, :wks_marc_record, :wks_eebo_citation_id, :wks_doc_directory,
                :wks_ecco_number, :wks_book_id, :wks_author, :wks_printer, :wks_word_count, :wks_title, :wks_eebo_image_id, :wks_eebo_url, :wks_pub_date,
                :wks_ecco_uncorrected_gale_ocr_path, :wks_corrected_xml_path, :wks_corrected_text_path, :wks_ecco_directory, :wks_ecco_gale_ocr_xml_path,
                :wks_organizational_unit, :wks_primary_print_font, :collection_id

  ## Controller customizations
  controller do
    skip_before_filter :get_dropdown_data
  end

  ## Index search filters
  filter :wks_work_id, label: 'ID'
  filter :collection
  filter :wks_title
  filter :wks_printer
  filter :wks_gt_number
  filter :wks_book_id

  ## INDEX
  index do
    column :id do |work|
      link_to work.id, admin_work_path(work)
    end
    column :collection
    column :wks_title
    column :wks_book_id
    column :wks_printer
    column :wks_gt_number
    actions
  end

  ## SHOW
  show do
    attributes_table do
      row :id
      row('Collection') do
        work.collection.name if work.collection.present?
      end
      row('GT Number') { |w| w.wks_gt_number }
      row('ESTC Number') { |w| w.wks_estc_number }
      row('Coll Name') { |w| w.wks_coll_name }
      row('TCP Bibno') { |w| w.wks_tcp_bibno }
      row('MARC Record') { |w| w.wks_marc_record }
      row('EEBO Citation ID') { |w| w.wks_eebo_citation_id }
      row('Doc Directory') { |w| w.wks_doc_directory }
      row('ECCO Number') { |w| w.wks_ecco_number }
      row('Book ID') { |w| w.wks_book_id }
      row('Author') { |w| w.wks_author }
      row('Printer') { |w| w.wks_printer }
      row('Word Count') { |w| w.wks_word_count }
      row('Title') { |w| w.wks_title }
      row('EEBO Image ID') { |w| w.wks_eebo_image_id }
      row('EEBO URL') { |w| w.wks_eebo_url }
      row('Pub Date') { |w| w.wks_pub_date }
      row('ECCO Uncorrected Gale OCR Path') { |w| w.wks_ecco_uncorrected_gale_ocr_path }
      row('Corrected XML Path') { |w| w.wks_corrected_xml_path }
      row('Corrected Text Path') { |w| w.wks_corrected_text_path }
      row('ECCO Directory') { |w| w.wks_ecco_directory }
      row('ECCO Gale OCR XML Path') { |w| w.wks_ecco_gale_ocr_xml_path }
      row('Organizational Unit') { |w| w.wks_organizational_unit }
      row('Primary Print Font') { |w| w.wks_primary_print_font } #TODO link to Admin PrintFont page
    end

    panel "Pages" do
      pages = work.pages
      paginated_collection(pages.page(params[:page]).per(15), download_links: false) do
        table_for collection do
          column :id do |p|
            link_to p.id, admin_page_path(p)
          end
          column :pg_ref_number
        end
      end
    end
  end

  ## NEW / EDIT
  form do |f|
    f.semantic_errors
    f.inputs do
      f.input :collection
      f.input :print_font
      f.input :wks_gt_number
      f.input :wks_estc_number
      f.input :wks_coll_name
      f.input :wks_tcp_bibno
      f.input :wks_marc_record
      f.input :wks_eebo_citation_id
      f.input :wks_doc_directory
      f.input :wks_ecco_number
      f.input :wks_book_id
      f.input :wks_author
      f.input :wks_printer
      f.input :wks_word_count
      f.input :wks_title
      f.input :wks_eebo_image_id
      f.input :wks_eebo_url
      f.input :wks_pub_date
      f.input :wks_ecco_uncorrected_gale_ocr_path
      f.input :wks_corrected_xml_path
      f.input :wks_corrected_text_path
      f.input :wks_ecco_directory
      f.input :wks_ecco_gale_ocr_xml_path
      f.input :wks_organizational_unit
    end
    f.actions
  end
end

{'fraction_non_alphanumeric': 0.10078947368421053, 'fraction_numerical': 0.0005263157894736842, 'mean_word_length': 2.9567933368037482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1255560', 'n_tokens_mistral': 3057, 'n_tokens_neox': 2936, 'n_words': 580}