Class: Karafka::Web::Pro::Ui::Controllers::ScheduledMessages::SchedulesController
- Inherits:
-
BaseController
- Object
- Controllers::BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::ScheduledMessages::SchedulesController
- Defined in:
- lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb
Overview
Controller to display list of schedules (groups) and details about each
Instance Method Summary collapse
-
#index ⇒ Object
Displays list of groups.
-
#show(schedule_name) ⇒ Object
Displays all partitions statistics (if any) with number of messages to dispatch.
Instance Method Details
#index ⇒ Object
Displays list of groups
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb', line 40 def index topics = Models::Topic.all # Names of scheduled messages topics defined in the routing # They may not exist (yet) so we filter them based on the existing topics in the # cluster candidates = Karafka::App .routes .map { |route| route.topics.to_a } .flatten .select(&:scheduled_messages?) .reject { |topic| topic.name.end_with?(states_postfix) } .map(&:name) .sort @topics = topics.select { |topic| candidates.include?(topic.topic_name) } render end |
#show(schedule_name) ⇒ Object
Displays all partitions statistics (if any) with number of messages to dispatch
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb', line 62 def show(schedule_name) @schedule_name = schedule_name @stats_topic_name = "#{schedule_name}#{states_postfix}" @stats_info = Karafka::Admin.topic_info(@stats_topic_name) @states = {} @stats_info[:partition_count].times { |i| @states[i] = false } Karafka::Pro::Iterator.new({ @stats_topic_name => -1 }).each do || @states[.partition] = .payload end # Sort by partition id @states = @states.sort_by { |key, _| key.to_s }.to_h # Sort daily from closest date @states.each_value do |details| # Skip false predefined values from sorting next unless details details[:daily] = details[:daily].sort_by { |key, _| key.to_s }.to_h end render end |