Class: RogIQ::Commands::Clients
- Defined in:
- lib/rogiq/commands/clients.rb
Instance Method Summary collapse
- #list ⇒ Object
- #onboarding(identifier) ⇒ Object
- #research_status(identifier) ⇒ Object
- #settings(identifier) ⇒ Object
- #show(identifier) ⇒ Object
- #subdomain(identifier) ⇒ Object
Instance Method Details
#list ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rogiq/commands/clients.rb', line 9 def list RogIQ.load_rails! scope = ::Client.order(created_at: :desc) scope = scope.where("name ILIKE ?", "%#{[:search]}%") if [:search].present? rows = scope.limit([:limit]).map do |c| slug = c.account&.slug [c.id, c.name, slug, c.research_ready, c.created_at.iso8601] end fmt.output(headers: %w[id name account_slug research_ready created_at], rows: rows) end |
#onboarding(identifier) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rogiq/commands/clients.rb', line 77 def onboarding(identifier) RogIQ.load_rails! c = RogIQ::Helpers.resolve_client(identifier) unless c fmt.error_msg("Client not found") exit 1 end ev = c.onboarding_evaluations.order(created_at: :desc).first ver = c.onboarding_versions.order(created_at: :desc).first fmt.output( { client_id: c.id, latest_evaluation: ev&.attributes, latest_version: ver&.attributes }.compact ) end |
#research_status(identifier) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rogiq/commands/clients.rb', line 47 def research_status(identifier) RogIQ.load_rails! c = RogIQ::Helpers.resolve_client(identifier) unless c fmt.error_msg("Client not found") exit 1 end row = c.client_settings.find_by(setting_key: "research_status") fmt.output(row ? row.setting_value : {}) end |
#settings(identifier) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rogiq/commands/clients.rb', line 60 def settings(identifier) RogIQ.load_rails! c = RogIQ::Helpers.resolve_client(identifier) unless c fmt.error_msg("Client not found") exit 1 end rows = c.client_settings.order(:setting_key).map do |s| val = s.setting_value preview = val.is_a?(Hash) ? val.to_json.truncate(120) : val.to_s.truncate(120) [s.setting_key, preview] end fmt.output(headers: %w[setting_key value_preview], rows: rows) end |
#show(identifier) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rogiq/commands/clients.rb', line 21 def show(identifier) RogIQ.load_rails! c = RogIQ::Helpers.resolve_client(identifier) unless c fmt.error_msg("Client not found: #{identifier}") exit 1 end payload = { id: c.id, name: c.name, account_id: c.account_id, account_slug: c.account&.slug, website: c.website, industry: c.industry, research_ready: c.research_ready, onboarding_stage: c.try(:onboarding_stage), onboarding_version: c.try(:onboarding_version), created_at: c.created_at, updated_at: c.updated_at } fmt.output(payload) end |
#subdomain(identifier) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rogiq/commands/clients.rb', line 97 def subdomain(identifier) RogIQ.load_rails! c = RogIQ::Helpers.resolve_client(identifier) unless c fmt.error_msg("Client not found") exit 1 end acc = c.account domains = acc ? ::CustomDomain.where(account_id: acc.id).limit(50).pluck(:domain, :status, :verified_at) : [] fmt.output( { account_slug: acc&.slug, account_id: acc&.id, custom_domains: domains.map { |d, st, v| { domain: d, status: st, verified_at: v } } } ) end |