that was definitely what was wrong with the stats

This commit is contained in:
Kyle Drake 2015-06-04 00:56:01 -07:00
parent 987d9789be
commit 781ea9c170

View file

@ -78,11 +78,11 @@ class Stat < Sequel::Model
DB[:stats].lock('EXCLUSIVE') { stat = Stat.create opts } if stat.nil?
DB[
'update stats set hits=hits+?, views=views+?, bandwidth=bandwidth+? where site_id=?',
'update stats set hits=hits+?, views=views+?, bandwidth=bandwidth+? where id=?',
site_log[:hits],
site_log[:views],
site_log[:bandwidth],
site_log[:id]
stat.id
].first
site_log[:referrers].each do |referrer, views|
@ -107,15 +107,6 @@ class Stat < Sequel::Model
FileUtils.rm log_path
end
end
def get_or_create
DB[:stats].lock 'EXCLUSIVE' do
stat = Stat.where(opts).first
stat ||= Stat.new opts
stat.hits += site_log[:hits]
stat.views += site_log[:views]
end
end
end
end