2013-06-13 20:26:27 +00:00
|
|
|
class ViewCounter
|
|
|
|
|
2013-09-25 14:58:44 +00:00
|
|
|
def increment(asciicast, storage)
|
2014-01-29 15:10:18 +00:00
|
|
|
key = "a#{asciicast.id}"
|
2013-09-25 14:58:44 +00:00
|
|
|
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
|