<commit_before>require 'test_helper'

class StatisticsTest < ActiveSupport::TestCase

  DAY_DATE    = Date.today - 1.day
  WEEK_DATE   = Date.today - 1.week - 2.day
  MONTH_DATE  = Date.today - 1.month - 2.day
  def test_daily_documents
    docs = DC::Statistics.daily_documents( MONTH_DATE )
    assert_equal 1, docs.detect{ |day, count| day.to_date == MONTH_DATE }.last
  end

  def test_daily_pages
    pgs = DC::Statistics.daily_pages( MONTH_DATE )
    assert_equal 68, pgs.detect{ |day, count| day.to_date == WEEK_DATE }.last
  end

  def test_weekly_documents
    docs = DC::Statistics.weekly_documents( Date.parse("2013-01-01") )
    assert_equal [1,1], docs.values
  end

  def test_weekly_pages
    pgs = DC::Statistics.weekly_pages
    assert_equal [68, 68 ], pgs.values
  end

  def test_daily_hits_on_documents
    hits = DC::Statistics.daily_hits_on_documents
    assert_equal 18, hits[ DAY_DATE ]
  end

  def test_weekly_hits_on_documents
    hits = DC::Statistics.weekly_hits_on_documents
    assert_equal [18, 122], hits.values
  end

  def test_daily_hits_on_notes
    hits = DC::Statistics.daily_hits_on_notes
    assert_equal [11,3].sort, hits.values.sort
  end

  def test_weekly_hits_on_notes
    hits = DC::Statistics.weekly_hits_on_notes
    assert_equal [3,11].sort, hits.values.sort
  end

  def test_daily_hits_on_searches
    hits = DC::Statistics.daily_hits_on_searches
    assert_equal 1, hits[ Date.today - 1.week ]
  end

  def test_weekly_hits_on_searches
    hits = DC::Statistics.weekly_hits_on_searches<commit_msg>Fix statistics test<commit_after>require 'test_helper'

class StatisticsTest < ActiveSupport::TestCase

  DAY_DATE    = Date.today - 1.day
  WEEK_DATE   = Date.today - 1.week - 2.day
  MONTH_DATE  = Date.today - 1.month - 2.day
  def test_daily_documents
    docs = DC::Statistics.daily_documents( MONTH_DATE )
    assert_equal 1, docs.detect{ |day, count| day.to_date == MONTH_DATE }.last
  end

  def test_daily_pages
    pgs = DC::Statistics.daily_pages( MONTH_DATE )
    assert_equal 68, pgs.detect{ |day, count| day.to_date == WEEK_DATE }.last
  end

  def test_weekly_documents
    docs = DC::Statistics.weekly_documents( Date.parse("2013-01-01") )
    assert_equal [1,1], docs.values
  end

  def test_weekly_pages
    pgs = DC::Statistics.weekly_pages
    assert_equal [68, 68 ], pgs.values
  end

  def test_daily_hits_on_documents
    hits = DC::Statistics.daily_hits_on_documents
    assert_equal 18, hits[ DAY_DATE ]
  end

  def test_weekly_hits_on_documents
    hits = DC::Statistics.weekly_hits_on_documents
    assert_equal [122, 18], hits.values
  end

  def test_daily_hits_on_notes
    hits = DC::Statistics.daily_hits_on_notes
    assert_equal [11,3].sort, hits.values.sort
  end

  def test_weekly_hits_on_notes
    hits = DC::Statistics.weekly_hits_on_notes
    assert_equal [3,11].sort, hits.values.sort
  end

  def test_daily_hits_on_searches
    hits = DC::Statistics.daily_hits_on_searches
    assert_equal 1, hits[ Date.today - 1.week ]
  end

  def test_weekly_hits_on_searches
    hits = DC::Statistics.weekly_hits_on_searches
{'fraction_non_alphanumeric': 0.08821635544108178, 'fraction_numerical': 0.023824855119124275, 'mean_word_length': 3.8622848200312987, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '940852', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1134, 'n_words': 221}