stat referrers, locations, and paths

This commit is contained in:
Kyle Drake 2015-05-02 02:34:24 -07:00
parent d9babf5cd6
commit 227b123fc9
10 changed files with 195 additions and 47 deletions

View file

@ -1,3 +1,15 @@
class StatPath < Sequel::Model
many_to_one :stat
RETAINMENT_PERIOD = 7.days
many_to_one :site
def self.create_or_get(site_id, name)
opts = {site_id: site_id, name: name}
stat_path = where(opts).where{created_at > RETAINMENT_PERIOD.ago}.first
DB[table_name].lock('EXCLUSIVE') {
stat_path = create opts.merge created_at: Date.today
} if stat_path.nil?
stat_path
end
end