Using created_at instead of legacy 'uploaddatetime' field
This commit is contained in:
parent
48ca75cb64
commit
3eeb9a63dc
6 changed files with 22 additions and 13 deletions
|
|
@ -2,7 +2,7 @@ class Screenshot < ActiveRecord::Base
|
|||
belongs_to :package, :inverse_of=>:screenshots
|
||||
|
||||
default_scope {
|
||||
order('uploaddatetime DESC')
|
||||
order('created_at DESC')
|
||||
}
|
||||
|
||||
has_attached_file :image,
|
||||
|
|
@ -29,7 +29,11 @@ class Screenshot < ActiveRecord::Base
|
|||
|
||||
# Calculate how many days ago this screenshot has been uploaded
|
||||
def age_days
|
||||
seconds = Time.now-self.uploaddatetime
|
||||
if self.created_at
|
||||
seconds = Time.now - self.created_at
|
||||
else
|
||||
seconds = 0
|
||||
end
|
||||
days = (seconds/86400).to_i
|
||||
days ? "#{days} days ago" : 'today'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
] Delete screenshot
|
||||
|
||||
p Uploader IP=#{screenshot.uploaderip}
|
||||
p Uploaded #{screenshot.age_days} (#{screenshot.uploaddatetime})
|
||||
p Uploaded #{screenshot.age_days} (#{screenshot.created_at})
|
||||
p Status: #{screenshot.status}
|
||||
|
||||
- else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue