<commit_before>require 'webmachine'

class History < Webmachine::Resource
  class << self
    attr_accessor :db
  end

  def run_query
    @query ||= self.class.db.history(requested_url)
  end

  def requested_url
    request.query['url']
  end

  def resource_exists?
    run_query

    @query.length > 0
  end

  def content_types_provided
    [['application/json', :to_json]]
  end

  def to_json
    run_query

    { 'rows' => @query }.to_json
  end
end<commit_msg>Dashboard: GET /history will always give you an answer.<commit_after>require 'webmachine'

class History < Webmachine::Resource
  class << self
    attr_accessor :db
  end

  def run_query
    @query ||= self.class.db.history(requested_url)
  end

  def requested_url
    request.query['url']
  end

  def content_types_provided
    [['application/json', :to_json]]
  end

  def to_json
    run_query

    { 'rows' => @query }.to_json
  end
end
{'fraction_non_alphanumeric': 0.09967141292442497, 'fraction_numerical': 0.001095290251916758, 'mean_word_length': 3.2119815668202767, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, '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': '7295186', 'n_tokens_mistral': 324, 'n_tokens_neox': 313, 'n_words': 77}