Class: RogIQ::Commands::Content
- Defined in:
- lib/rogiq/commands/content.rb
Instance Method Summary collapse
- #failed(client_identifier) ⇒ Object
- #heal(client_identifier) ⇒ Object
- #publish_queue ⇒ Object
- #status(client_identifier) ⇒ Object
Instance Method Details
#failed(client_identifier) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rogiq/commands/content.rb', line 55 def failed(client_identifier) RogIQ.load_rails! client = RogIQ::Helpers.resolve_client(client_identifier) unless client fmt.error_msg("Client not found") exit 1 end rows = ::ContentItem.where(client_id: client.id, state: %w[failed rejected]) .order(updated_at: :desc) .limit([:limit]) .map { |i| [i.id, i.title.to_s.truncate(60), i.state, i.updated_at.iso8601] } fmt.output(headers: %w[id title state updated_at], rows: rows) end |
#heal(client_identifier) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rogiq/commands/content.rb', line 20 def heal(client_identifier) RogIQ.load_rails! client = RogIQ::Helpers.resolve_client(client_identifier) unless client fmt.error_msg("Client not found") exit 1 end ::DataHealingOrchestratorJob.perform_later(client_id: client.id, account_id: client.account_id) fmt.success("DataHealingOrchestratorJob enqueued for client #{client.id}.") end |
#publish_queue ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rogiq/commands/content.rb', line 35 def publish_queue RogIQ.load_rails! rows = ::ContentPublication.where(status: "scheduled") .where("scheduled_at > ?", Time.current) .order(:scheduled_at) .limit([:limit]) .map do |p| [ p.id, p.account_id, p.title.to_s.truncate(50), p.scheduled_at&.iso8601, p.platform ] end fmt.output(headers: %w[id account_id title scheduled_at platform], rows: rows) end |
#status(client_identifier) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rogiq/commands/content.rb', line 7 def status(client_identifier) RogIQ.load_rails! client = RogIQ::Helpers.resolve_client(client_identifier) unless client fmt.error_msg("Client not found") exit 1 end counts = ::ContentItem.where(client_id: client.id).group(:state).count.sort_by { |_, n| -n } fmt.output(headers: %w[state count], rows: counts.to_a) end |