1 class UprStatus < ActiveRecord::Base
2 cattr_accessor :gc_cutoff
10 def start(upid, length)
11 # this must be a find_or_create_by since some users have twitchy
12 # fingers and hit the upload button prematurely
13 find_or_create_by_upid(upid) do |x|
15 x.time = Time.now.to_i
21 update_all("seen = seen + #{nr.to_i}, time = #{Time.now.to_i}",
22 [ "upid = ? AND seen >= 0", upid ])
27 if rv = find_by_upid(upid)
28 rv.time = Time.now.to_i
38 if rv = find_by_upid(upid)
39 rv.time = Time.now.to_i
49 cutoff = Time.now.to_i - @@gc_cutoff
50 delete_all "time < #{cutoff}"
54 include Upr::StatusMethods