2013-06-13 20:26:27 +00:00
|
|
|
class ViewCounter
|
|
|
|
|
2013-09-25 14:58:44 +00:00
|
|
|
def increment(asciicast, storage)
|
|
|
|
key = :"asciicast_#{asciicast.id}_viewed"
|
|
|
|
return if storage[key]
|
2013-06-13 20:26:27 +00:00
|
|
|
|
2013-09-25 14:58:44 +00:00
|
|
|
Asciicast.increment_counter(:views_count, asciicast.id)
|
|
|
|
asciicast.reload
|
|
|
|
storage[key] = '1'
|
2013-06-13 20:26:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|