Updated

app/models / account.rb

A
129 lines of codes
18 methods
1.1 complexity/method
38 churn
19.79 complexity
0 duplications
# == Schema Information # # Table name: accounts # # id :bigint not null, primary key # ai_usage :jsonb not null # currency_code :string default("BRL"), not null # name :string default(""), not null # number_of_employees :string default("1-10"), not null # segment :string default("other"), not null # settings :jsonb not null # site_url :string default(""), not null # woofbot_auto_reply :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null # class Account < ApplicationRecord
  1. Account has at least 18 methods
include Account::Settings validates :name, presence: true validates :name, length: { maximum: 255 } validates :currency_code, presence: true, inclusion: { in: Money::Currency.table.keys.map(&:to_s).map(&:upcase) } enum segment: { technology: 'technology', health: 'health', finance: 'finance', education: 'education', retail: 'retail', services: 'services', manufacturing: 'manufacturing', telecommunications: 'telecommunications', transportation_logistics: 'transportation_logistics', real_estate: 'real_estate', energy: 'energy', agriculture: 'agriculture', tourism_hospitality: 'tourism_hospitality', entertainment_media: 'entertainment_media', construction: 'construction', public_sector: 'public_sector', consulting: 'consulting', startup: 'startup', ecommerce: 'ecommerce', security: 'security', automotive: 'automotive', other: 'other' } enum number_of_employees: { '1-10' => '1-10', '11-50' => '11-50', '51-200' => '51-200', '201-500' => '201-500', '501+' => '501+' } def events
  1. Account#events doesn't depend on instance state (maybe move it to another class?)
Event.all end def apps
  1. Account#apps doesn't depend on instance state (maybe move it to another class?)
App.all end def users
  1. Account#users doesn't depend on instance state (maybe move it to another class?)
User.all end def contacts
  1. Account#contacts doesn't depend on instance state (maybe move it to another class?)
Contact.all end def deals
  1. Account#deals doesn't depend on instance state (maybe move it to another class?)
Deal.all end def custom_attribute_definitions
  1. Account#custom_attribute_definitions doesn't depend on instance state (maybe move it to another class?)
CustomAttributeDefinition.all end def custom_attributes_definitions custom_attribute_definitions end def apps_wpp_connects
  1. Account#apps_wpp_connects doesn't depend on instance state (maybe move it to another class?)
Apps::WppConnect.all end def apps_chatwoots
  1. Account#apps_chatwoots doesn't depend on instance state (maybe move it to another class?)
Apps::Chatwoot.all end def apps_evolution_apis
  1. Account#apps_evolution_apis doesn't depend on instance state (maybe move it to another class?)
Apps::EvolutionApi.all end def webhooks
  1. Account#webhooks doesn't depend on instance state (maybe move it to another class?)
Webhook.all end def stages
  1. Account#stages doesn't depend on instance state (maybe move it to another class?)
Stage.all end def products
  1. Account#products doesn't depend on instance state (maybe move it to another class?)
Product.all end def embedding_documments
  1. Account#embedding_documments doesn't depend on instance state (maybe move it to another class?)
EmbeddingDocumment.all end def deal_products
  1. Account#deal_products doesn't depend on instance state (maybe move it to another class?)
DealProduct.all end def apps_ai_assistents
  1. Account#apps_ai_assistents doesn't depend on instance state (maybe move it to another class?)
Apps::AiAssistent.all end def site_url=(url) super(normalize_url(url)) end def normalize_url(url)
  1. Account#normalize_url doesn't depend on instance state (maybe move it to another class?)
url = "https://#{url}" unless url.match?(%r{\Ahttp(s)?://}) url end end