mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 00:31:59 +02:00
mostly finished port to ruby3
This commit is contained in:
parent
a9dd102383
commit
0ca1473d22
30 changed files with 765 additions and 731 deletions
|
@ -33,9 +33,9 @@ describe 'stats' do
|
|||
end
|
||||
Stat.parse_logfiles STAT_LOGS_PATH
|
||||
stat = @site_one.stats.first
|
||||
stat.hits.must_equal 8
|
||||
stat.bandwidth.must_equal 40000
|
||||
stat.views.must_equal 2
|
||||
_(stat.hits).must_equal 8
|
||||
_(stat.bandwidth).must_equal 40000
|
||||
_(stat.views).must_equal 2
|
||||
end
|
||||
|
||||
it 'deals with spaces in paths' do
|
||||
|
@ -48,9 +48,9 @@ describe 'stats' do
|
|||
|
||||
Stat.parse_logfiles STAT_LOGS_PATH
|
||||
|
||||
@site.stats.first.bandwidth.must_equal 612917*2
|
||||
#@site.stat_referrers.first.url.must_equal 'http://derp.com'
|
||||
#@site.stat_locations.first.city_name.must_equal 'Menlo Park'
|
||||
_(@site.stats.first.bandwidth).must_equal 612917*2
|
||||
#_(@site.stat_referrers.first.url).must_equal 'http://derp.com'
|
||||
#_(@site.stat_locations.first.city_name).must_equal 'Menlo Park'
|
||||
end
|
||||
|
||||
it 'takes accout for log hit time' do
|
||||
|
@ -63,15 +63,15 @@ describe 'stats' do
|
|||
|
||||
Stat.parse_logfiles STAT_LOGS_PATH
|
||||
|
||||
@site.stats.length.must_equal 2
|
||||
_(@site.stats.length).must_equal 2
|
||||
|
||||
[Date.new(2015, 5, 2), Date.new(2015, 5, 1)].each do |date|
|
||||
stats = @site.stats.select {|stat| stat.created_at == date}
|
||||
stats.length.must_equal 1
|
||||
_(stats.length).must_equal 1
|
||||
stat = stats.first
|
||||
stat.hits.must_equal 1
|
||||
stat.views.must_equal 1
|
||||
stat.bandwidth.must_equal 612917
|
||||
_(stat.hits).must_equal 1
|
||||
_(stat.views).must_equal 1
|
||||
_(stat.bandwidth).must_equal 612917
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -101,20 +101,20 @@ describe 'stats' do
|
|||
count_site_ids = [@free_site.id, @supporter_site.id]
|
||||
expected_stat_count = (Stat::FREE_RETAINMENT_DAYS+1)*2
|
||||
|
||||
Stat.where(site_id: count_site_ids).count.must_equal expected_stat_count
|
||||
_(Stat.where(site_id: count_site_ids).count).must_equal expected_stat_count
|
||||
Stat.prune!
|
||||
Stat.where(site_id: count_site_ids).count.must_equal expected_stat_count-1
|
||||
Stat.where(site_id: @supporter_site.id).count.must_equal expected_stat_count/2
|
||||
_(Stat.where(site_id: count_site_ids).count).must_equal expected_stat_count-1
|
||||
_(Stat.where(site_id: @supporter_site.id).count).must_equal expected_stat_count/2
|
||||
end
|
||||
|
||||
it 'prunes referrers' do
|
||||
stat_referrer_now = @site_one.add_stat_referrer created_at: Date.today, url: 'http://example.com/now'
|
||||
stat_referrer = @site_one.add_stat_referrer created_at: (StatReferrer::RETAINMENT_DAYS-1).days.ago, url: 'http://example.com'
|
||||
StatReferrer[stat_referrer.id].wont_be_nil
|
||||
@site_one.stat_referrers_dataset.count.must_equal 2
|
||||
_(StatReferrer[stat_referrer.id]).wont_be_nil
|
||||
_(@site_one.stat_referrers_dataset.count).must_equal 2
|
||||
StatReferrer.prune!
|
||||
@site_one.stat_referrers_dataset.count.must_equal 1
|
||||
StatReferrer[stat_referrer.id].must_be_nil
|
||||
_(@site_one.stat_referrers_dataset.count).must_equal 1
|
||||
_(StatReferrer[stat_referrer.id]).must_be_nil
|
||||
end
|
||||
|
||||
it 'prunes locations' do
|
||||
|
@ -124,9 +124,9 @@ describe 'stats' do
|
|||
region_name: 'Minnesota',
|
||||
city_name: 'Minneapolis'
|
||||
)
|
||||
StatLocation[stat_location.id].wont_be_nil
|
||||
_(StatLocation[stat_location.id]).wont_be_nil
|
||||
StatLocation.prune!
|
||||
StatLocation[stat_location.id].must_be_nil
|
||||
_(StatLocation[stat_location.id]).must_be_nil
|
||||
end
|
||||
|
||||
it 'prunes paths' do
|
||||
|
@ -134,9 +134,9 @@ describe 'stats' do
|
|||
created_at: (StatPath::RETAINMENT_DAYS-1).days.ago,
|
||||
name: '/derpie.html'
|
||||
)
|
||||
StatPath[stat_path.id].wont_be_nil
|
||||
_(StatPath[stat_path.id]).wont_be_nil
|
||||
StatPath.prune!
|
||||
StatPath[stat_path.id].must_be_nil
|
||||
_(StatPath[stat_path.id]).must_be_nil
|
||||
end
|
||||
|
||||
it 'parses logfile' do
|
||||
|
@ -144,57 +144,57 @@ describe 'stats' do
|
|||
Stat.parse_logfiles STAT_LOGS_PATH
|
||||
|
||||
@site_one.reload
|
||||
@site_one.hits.must_equal 4
|
||||
@site_one.views.must_equal 2
|
||||
_(@site_one.hits).must_equal 4
|
||||
_(@site_one.views).must_equal 2
|
||||
stat = @site_one.stats.first
|
||||
stat.hits.must_equal 4
|
||||
stat.views.must_equal 2
|
||||
stat.bandwidth.must_equal 20_000
|
||||
_(stat.hits).must_equal 4
|
||||
_(stat.views).must_equal 2
|
||||
_(stat.bandwidth).must_equal 20_000
|
||||
|
||||
#@site_one.stat_referrers.count.must_equal 1
|
||||
#@site_one.stat_referrers.count).must_equal 1
|
||||
#stat_referrer = @site_one.stat_referrers.first
|
||||
#stat_referrer.url.must_equal 'http://example.com'
|
||||
#stat_referrer.created_at.must_equal @time.to_date
|
||||
#stat_referrer.views.must_equal 2
|
||||
#stat_referrer.url).must_equal 'http://example.com'
|
||||
#stat_referrer.created_at).must_equal @time.to_date
|
||||
#stat_referrer.views).must_equal 2
|
||||
|
||||
#@site_one.stat_paths.length.must_equal 1
|
||||
#@site_one.stat_paths.length).must_equal 1
|
||||
#stat_path = @site_one.stat_paths.first
|
||||
#stat_path.name.must_equal '/'
|
||||
#stat_path.views.must_equal 4
|
||||
#stat_path.name).must_equal '/'
|
||||
#stat_path.views).must_equal 4
|
||||
|
||||
#@site_one.stat_locations.length.must_equal 2
|
||||
#@site_one.stat_locations.length).must_equal 2
|
||||
#stat_location = @site_one.stat_locations.first
|
||||
#stat_location.country_code2.must_equal 'US'
|
||||
#stat_location.region_name.must_equal 'CA'
|
||||
#stat_location.city_name.must_equal 'Menlo Park'
|
||||
#stat_location.views.must_equal 1
|
||||
#stat_location.country_code2).must_equal 'US'
|
||||
#stat_location.region_name).must_equal 'CA'
|
||||
#stat_location.city_name).must_equal 'Menlo Park'
|
||||
#stat_location.views).must_equal 1
|
||||
|
||||
@site_two.reload
|
||||
@site_two.hits.must_equal 3
|
||||
@site_two.views.must_equal 3
|
||||
_(@site_two.hits).must_equal 3
|
||||
_(@site_two.views).must_equal 3
|
||||
stat = @site_two.stats.first
|
||||
stat.hits.must_equal 3
|
||||
stat.views.must_equal 3
|
||||
stat.bandwidth.must_equal 15_000
|
||||
#@site_two.stat_referrers.count.must_equal 2
|
||||
_(stat.hits).must_equal 3
|
||||
_(stat.views).must_equal 3
|
||||
_(stat.bandwidth).must_equal 15_000
|
||||
#@site_two.stat_referrers.count).must_equal 2
|
||||
#stat_referrer = @site_two.stat_referrers.first
|
||||
#stat_referrer.url.must_equal 'http://example.com'
|
||||
#stat_referrer.views.must_equal 2
|
||||
#stat_referrer.url).must_equal 'http://example.com'
|
||||
#stat_referrer.views).must_equal 2
|
||||
|
||||
#stat_paths = @site_two.stat_paths
|
||||
#stat_paths.length.must_equal 2
|
||||
#stat_paths.first.name.must_equal '/'
|
||||
#stat_paths.last.name.must_equal '/derp.html'
|
||||
#stat_paths.length).must_equal 2
|
||||
#stat_paths.first.name).must_equal '/'
|
||||
#stat_paths.last.name).must_equal '/derp.html'
|
||||
|
||||
# [geoip.city('67.180.75.140'), geoip.city('172.56.16.152')]
|
||||
|
||||
# Saves to daily_site_stats
|
||||
|
||||
DailySiteStat.count.must_equal 1
|
||||
_(DailySiteStat.count).must_equal 1
|
||||
d = DailySiteStat.first
|
||||
d.created_at.must_equal Date.new(@time.year, @time.month, @time.day)
|
||||
d.hits.must_equal 7
|
||||
d.views.must_equal 5
|
||||
d.bandwidth.must_equal 35000
|
||||
_(d.created_at).must_equal Date.new(@time.year, @time.month, @time.day)
|
||||
_(d.hits).must_equal 7
|
||||
_(d.views).must_equal 5
|
||||
_(d.bandwidth).must_equal 35000
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue