mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
Only record visit stats for now, need to rethink
This commit is contained in:
parent
c9b4393dce
commit
a9e142dee0
3 changed files with 40 additions and 32 deletions
|
@ -85,6 +85,7 @@ class Stat < Sequel::Model
|
|||
stat.id
|
||||
].first
|
||||
|
||||
=begin
|
||||
site_log[:referrers].each do |referrer, views|
|
||||
stat_referrer = StatReferrer.create_or_get site_log[:id], referrer
|
||||
DB['update stat_referrers set views=views+? where site_id=?', views, site_log[:id]].first
|
||||
|
@ -101,6 +102,7 @@ class Stat < Sequel::Model
|
|||
next if site_path.nil?
|
||||
DB['update stat_paths set views=views+? where id=?', views, site_path.id].first
|
||||
end
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ 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.stat_referrers.first.url.must_equal 'http://derp.com'
|
||||
#@site.stat_locations.first.city_name.must_equal 'Menlo Park'
|
||||
end
|
||||
|
||||
it 'deals with spaces in referrer' do
|
||||
|
@ -112,23 +112,24 @@ describe 'stats' do
|
|||
stat.hits.must_equal 4
|
||||
stat.views.must_equal 2
|
||||
stat.bandwidth.must_equal 20_000
|
||||
@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
|
||||
|
||||
@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
|
||||
#@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
|
||||
|
||||
@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
|
||||
#@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
|
||||
|
||||
#@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
|
||||
|
||||
@site_two.reload
|
||||
@site_two.hits.must_equal 3
|
||||
|
@ -137,15 +138,15 @@ describe 'stats' do
|
|||
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
|
||||
#@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_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 = @site_two.stat_paths
|
||||
#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')]
|
||||
end
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
<div class="content misc-page columns right-col">
|
||||
<div class="col-left">
|
||||
<div class="col col-66">
|
||||
<!--
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col col-100 globe">
|
||||
<div id="earth_div"></div>
|
||||
</div>
|
||||
|
@ -130,8 +132,9 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
-->
|
||||
|
||||
</div>
|
||||
-->
|
||||
|
||||
<h2>Total Visitors <small>last 7 days</small></h2>
|
||||
|
||||
|
@ -151,6 +154,7 @@
|
|||
|
||||
<canvas id="myChart" style="width:100%;height:300px;display:block"></canvas>
|
||||
|
||||
<!--
|
||||
<div class="row">
|
||||
<div class="col col-50">
|
||||
<h2>Top Paths <small>last 7 days</small></h2>
|
||||
|
@ -219,6 +223,7 @@
|
|||
</div>
|
||||
|
||||
<% end %>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div class="col col-33">
|
||||
|
@ -250,11 +255,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="//www.webglearth.com/v2/api.js"></script>
|
||||
<!-- <script src="//www.webglearth.com/v2/api.js"></script> -->
|
||||
<script src="/js/Chart.min.js"></script>
|
||||
<script>
|
||||
//OpenGL globe
|
||||
$(document).ready(function() {
|
||||
/*
|
||||
var options = {
|
||||
sky: true,
|
||||
atmosphere: false,
|
||||
|
@ -267,11 +273,9 @@
|
|||
var earth = new WE.map('earth_div', options)
|
||||
earth.setView([20, -100], 2.07)
|
||||
|
||||
/*
|
||||
WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
|
||||
attribution: '© OpenStreetMap'
|
||||
}).addTo(earth);
|
||||
*/
|
||||
// WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
|
||||
// attribution: '© OpenStreetMap'
|
||||
//}).addTo(earth);
|
||||
|
||||
WE.tileLayer('http://data.webglearth.com/natural-earth-color/{z}/{x}/{y}.jpg', {
|
||||
tileSize: 256,
|
||||
|
@ -298,6 +302,7 @@
|
|||
earth.setCenter([c[0], c[1] + 0.1*(elapsed/30)])
|
||||
requestAnimationFrame(animate)
|
||||
});
|
||||
*/
|
||||
|
||||
//chart.js
|
||||
var data = {
|
||||
|
|
Loading…
Add table
Reference in a new issue