Class: RogIQ::Commands::SEO

Inherits:
Base
  • Object
show all
Defined in:
lib/rogiq/commands/seo.rb

Instance Method Summary collapse

Instance Method Details

#insights(client_identifier) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rogiq/commands/seo.rb', line 25

def insights(client_identifier)
  RogIQ.load_rails!
  client = RogIQ::Helpers.resolve_client(client_identifier)
  unless client
    fmt.error_msg("Client not found")
    exit 1
  end

  scope = ::SearchInsight.where(client_id: client.id)
  fmt.output(
    total: scope.count,
    by_status: scope.group(:status).count
  )
end

#keywords(client_identifier) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rogiq/commands/seo.rb', line 10

def keywords(client_identifier)
  RogIQ.load_rails!
  client = RogIQ::Helpers.resolve_client(client_identifier)
  unless client
    fmt.error_msg("Client not found")
    exit 1
  end

  rows = client.client_seo_track_keywords.order(:sort_order, :keyword).limit(200).map do |k|
    [k.keyword, k.sort_order, k.source]
  end
  fmt.output(headers: %w[keyword sort_order source], rows: rows)
end

#zeitwerkObject



41
42
43
44
45
46
# File 'lib/rogiq/commands/seo.rb', line 41

def zeitwerk
  fmt.warn_msg("Running zeitwerk:check with RAILS_ENV=production …")
  api = RogIQ.api_root
  ok = system({ "RAILS_ENV" => "production" }, "bundle", "exec", "rails", "zeitwerk:check", chdir: api)
  exit(ok ? 0 : 1)
end