mirror of
https://github.com/neocities/neocities.git
synced 2025-06-27 14:44:35 +02:00
stat referrers, locations, and paths
This commit is contained in:
parent
d9babf5cd6
commit
227b123fc9
10 changed files with 195 additions and 47 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue