set ceiling for traffic counter
This commit is contained in:
parent
92c2e85b0a
commit
6eca2ed75d
1 changed files with 5 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
@@_css_link_header = nil
|
||||
|
||||
TRAFFIC_DECREMENTER = 0.25
|
||||
TRAFFIC_DECREMENTER = 0.30
|
||||
|
||||
TAG_FILTER_COOKIE = :tag_filters
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ class ApplicationController < ActionController::Base
|
|||
traffic = traffic_kv.value.to_i + 100
|
||||
# every second, decrement traffic by some amount
|
||||
traffic -= (100.0 * (now_i - date_kv.value) * TRAFFIC_DECREMENTER).to_i
|
||||
# clamp
|
||||
traffic = [ 100, traffic ].max
|
||||
# clamp to 100, 1000
|
||||
traffic = [ [ 100, traffic ].max, 10000 ].min
|
||||
|
||||
@traffic = traffic * 0.01
|
||||
|
||||
|
|
@ -70,9 +70,9 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
date_kv.value = now_i
|
||||
date_kv.save!
|
||||
end
|
||||
|
||||
Rails.logger.info " Traffic level: #{@traffic}"
|
||||
Rails.logger.info " Traffic level: #{@traffic} (#{traffic})"
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue