priv users now have 6sec timeout, platinum users have 9sec timeout
This commit is contained in:
@@ -168,6 +168,10 @@ class AnonymousUser
|
||||
def api_hourly_limit
|
||||
500
|
||||
end
|
||||
|
||||
def statement_timeout
|
||||
3_000
|
||||
end
|
||||
|
||||
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
|
||||
define_method("is_#{name}?") do
|
||||
|
||||
@@ -25,9 +25,15 @@ class SessionLoader
|
||||
|
||||
update_last_logged_in_at
|
||||
set_time_zone
|
||||
set_statement_timeout
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_statement_timeout
|
||||
timeout = CurrentUser.user.statement_timeout
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = #{timeout}")
|
||||
end
|
||||
|
||||
def load_session_for_api
|
||||
if request.authorization
|
||||
|
||||
@@ -479,6 +479,16 @@ class User < ActiveRecord::Base
|
||||
3_000
|
||||
end
|
||||
end
|
||||
|
||||
def statement_timeout
|
||||
if is_platinum?
|
||||
9_000
|
||||
elsif is_privileged?
|
||||
6_000
|
||||
else
|
||||
3_000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ApiMethods
|
||||
|
||||
@@ -67,6 +67,18 @@
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>API Hourly Limit</td>
|
||||
<td>3,000</td>
|
||||
<td>10,000</td>
|
||||
<td>20,000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Database Timeout</td>
|
||||
<td>3 sec</td>
|
||||
<td>6 sec</td>
|
||||
<td>9 sec</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user