From 09ed4ae3c16935a18888544e4ade1de280403980 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 17 Jan 2025 15:35:59 +0530 Subject: [PATCH] refactor: don't use magic strings --- enterprise/app/models/enterprise/account.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/enterprise/app/models/enterprise/account.rb b/enterprise/app/models/enterprise/account.rb index a45f91d38..f8450b12d 100644 --- a/enterprise/app/models/enterprise/account.rb +++ b/enterprise/app/models/enterprise/account.rb @@ -1,4 +1,6 @@ module Enterprise::Account + ACCOUNT_RESPONSES_LIMIT = 'ACCOUNT_RESPONSES_LIMIT'.freeze + def usage_limits { agents: agent_limits.to_i, @@ -33,7 +35,7 @@ module Enterprise::Account consumed = if type == :documents captain_documents.available.count else - self[:limits]['ACCOUNT_RESPONSES_LIMIT'] || 0 + self[:limits][ACCOUNT_RESPONSES_LIMIT] || 0 end { @@ -44,13 +46,14 @@ module Enterprise::Account end def increment_response_usage - config_name = 'ACCOUNT_RESPONSES_LIMIT' + config_name = ACCOUNT_RESPONSES_LIMIT + self[:limits][config_name] = 0 if self[:limits][config_name].blank? self[:limits][config_name] = self[:limits][config_name].to_i + 1 save end def reset_response_usage - config_name = 'ACCOUNT_RESPONSES_LIMIT' + config_name = ACCOUNT_RESPONSES_LIMIT self[:limits][config_name] = 0 save end