This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
/
statistics_test.rb
133 lines (104 loc) · 3.98 KB
/
statistics_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
assert_equal [1, 11, 13].sort, hits.values.sort
end
def test_pages_since
assert_equal 68, DC::Statistics.pages_since( WEEK_DATE - 1.day )
end
def test_public_documents_per_account
counts = DC::Statistics.public_documents_per_account
assert_equal 1, counts[ louis.id ]
end
def test_private_documents_per_account
counts = DC::Statistics.private_documents_per_account
assert_equal 1, counts[ louis.id ]
end
def test_pages_per_account
counts = DC::Statistics.pages_per_account
assert_equal 136, counts[ louis.id ]
end
def test_total_pages
assert_equal 136, DC::Statistics.total_pages
end
def test_by_the_numbers
nums = DC::Statistics.by_the_numbers
assert_equal( {:total=>3, :day=>3, :week=>3, :month=>3, :half_year=>3} , nums["All Organizations"] )
assert_equal( {:total=>1, :day=>1, :week=>1, :month=>1, :half_year=>1} , nums["Active Organizations"] )
assert_equal( {:total=>4, :day=>4, :week=>4, :month=>4, :half_year=>4} , nums["All Accounts"] )
assert_equal( {:total=>1, :day=>1, :week=>1, :month=>1, :half_year=>1} , nums["Active Accounts"] )
assert_equal( {:total=>0, :day=>0, :week=>0, :month=>0, :half_year=>0} , nums["Reviewers"] )
assert_equal( {:total=>2, :day=>0, :week=>0, :month=>1, :half_year=>2} , nums["Documents"] )
assert_equal( {:total=>136, :day=>0, :week=>0, :month=>68, :half_year=>136} , nums["Pages"] )
assert_equal( {:total=>3, :day=>3, :week=>3, :month=>3, :half_year=>3} , nums["Notes"] )
end
def test_pages_per_minute
assert_equal 0, DC::Statistics.pages_per_minute
end
def test_documents_by_access
docs = DC::Statistics.documents_by_access
assert_equal 1, docs[ Document::PRIVATE ]
assert_equal 1, docs[ Document::PUBLIC ]
end
def test_averate_page_count
assert_equal 68, DC::Statistics.average_page_count
end
def test_average_entity_count
assert_equal 1, DC::Statistics.average_entity_count
end
def test_embedded_document_count
assert_equal 1, DC::Statistics.embedded_document_count
end
def test_remote_url_hits_last_week
assert_equal 31, DC::Statistics.remote_url_hits_last_week
end
def test_remote_url_hits_all_time
assert_equal 179, DC::Statistics.remote_url_hits_all_time
end
def test_count_organizations_embedding
assert_equal 1, DC::Statistics.count_organizations_embedding
end
def test_count_total_collaborators
assert_equal 0, DC::Statistics.count_total_collaborators
end
end