<commit_before>class AdminController < ApplicationController
  #before_action :authenticate_user!
  #before_filter :authenticate!

  before_filter :check_admin

  def db_stats
    stats = {
      :articles => get_stats(Article),
      :authors => get_stats(Author),
      :invites => get_stats(Invite),
      :links => get_stats(Link),
      :replications => get_stats(Replication),
      :studies => get_stats(Study),
      :users => get_stats(User)
    }

    render json: stats
  rescue StandardError => ex
    Raven.capture_exception(ex)
    render json: {error: ex.to_s}, status: 500
  end

  private

  def get_stats(model)
    {
      :total => model.count,
      :last_day => {
        :created => model.where("created_at > ?", 1.day.ago).count,
        :updated => model.where("updated_at > ?", 1.day.ago).count
      }
    }
  end
end
<commit_msg>AdminController#db_stats: add bookmarks and model_updates stats<commit_after>class AdminController < ApplicationController
  #before_action :authenticate_user!
  #before_filter :authenticate!

  before_filter :check_admin

  def db_stats
    stats = {
      :articles => get_stats(Article),
      :authors => get_stats(Author),
      :bookmarks => get_stats(UserBookmark),
      :invites => get_stats(Invite),
      :links => get_stats(Link),
      :model_updates => get_stats(ModelUpdate),
      :replications => get_stats(Replication),
      :studies => get_stats(Study),
      :users => get_stats(User)
    }

    render json: stats
  rescue StandardError => ex
    Raven.capture_exception(ex)
    render json: {error: ex.to_s}, status: 500
  end

  private

  def get_stats(model)
    {
      :total => model.count,
      :last_day => {
        :created => model.where("created_at > ?", 1.day.ago).count,
        :updated => model.where("updated_at > ?", 1.day.ago).count
      }
    }
  end
end

{'fraction_non_alphanumeric': 0.12708669897684438, 'fraction_numerical': 0.005385029617662897, 'mean_word_length': 3.074561403508772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '3085832', 'n_tokens_mistral': 625, 'n_tokens_neox': 594, 'n_words': 117}