<commit_before>ActiveAdmin.register_page "Dashboard" do

  menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }

  content title: proc{ I18n.t("active_admin.dashboard") } do
    columns do
      column do
        panel "Users" do
          para "#{User.where("created_at > ?", 7.days.ago).count} new users in last 7 days"
          para "#{User.count} users total"
        end
      end

      column do
        panel "Scrapers" do
          para "#{Scraper.where("created_at > ?", 7.days.ago).count} new scrapers in last 7 days"
          para "#{Scraper.count} scrapers total"
        end
      end
    end

    div class: "blank_slate_container", id: "dashboard_default_message" do
      para do
        if SiteSetting.read_only_mode
          button_to "Switch off site-wide read-only mode", toggle_read_only_mode_admin_site_settings_path
        else
          button_to "Go into site-wide read-only mode", toggle_read_only_mode_admin_site_settings_path
        end
      end
      para do
        render "maximum_concurrent_scrapers_form"
      end
    end

    panel "Sqlite database not transferred bug debugging help" do
      para do
        text_node "This is here to help debug the issue"
        a "https://github.com/openaustralia/morph/issues/1064", href: "https://github.com/openaustralia/morph/issues/1064"
      end
      # For the time being just look at runs in the last month
      runs = Run.order(finished_at: :desc).where(status_code: 998).where('finished_at > ?', 1.month.ago)
      # Only highlight runs where there is actually data.sqlite stored on the server because
      # we would always expect there to be a data.sqlite output
      run = runs.find do |r|
        File.exists?(File.join(runs.first.data_path, 'data.sqlite'))
      end
      if run
        time = run.finished_at.localtime<commit_msg>Oops. Let's make that last commit actually work<commit_after>ActiveAdmin.register_page "Dashboard" do

  menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }

  content title: proc{ I18n.t("active_admin.dashboard") } do
    columns do
      column do
        panel "Users" do
          para "#{User.where("created_at > ?", 7.days.ago).count} new users in last 7 days"
          para "#{User.count} users total"
        end
      end

      column do
        panel "Scrapers" do
          para "#{Scraper.where("created_at > ?", 7.days.ago).count} new scrapers in last 7 days"
          para "#{Scraper.count} scrapers total"
        end
      end
    end

    div class: "blank_slate_container", id: "dashboard_default_message" do
      para do
        if SiteSetting.read_only_mode
          button_to "Switch off site-wide read-only mode", toggle_read_only_mode_admin_site_settings_path
        else
          button_to "Go into site-wide read-only mode", toggle_read_only_mode_admin_site_settings_path
        end
      end
      para do
        render "maximum_concurrent_scrapers_form"
      end
    end

    panel "Sqlite database not transferred bug debugging help" do
      para do
        text_node "This is here to help debug the issue"
        a "https://github.com/openaustralia/morph/issues/1064", href: "https://github.com/openaustralia/morph/issues/1064"
      end
      # For the time being just look at runs in the last month
      runs = Run.order(finished_at: :desc).where(status_code: 998).where('finished_at > ?', 1.month.ago)
      # Only highlight runs where there is actually data.sqlite stored on the server because
      # we would always expect there to be a data.sqlite output
      run = runs.find do |r|
        File.exists?(File.join(r.data_path, 'data.sqlite'))
      end
      if run
        time = run.finished_at.localtime
{'fraction_non_alphanumeric': 0.08909825033647376, 'fraction_numerical': 0.011305518169582772, 'mean_word_length': 2.579961464354528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '1166234', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1131, 'n_words': 338}