Sha256: b5c92288b240c0ba360519a7a346807d4a5fced190c325f618fbb34420492891

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require_dependency 'kafka_command/application_controller'

module KafkaCommand
  class ConsumerGroupsController < ApplicationController
    # GET /clusters/:cluster_id/consumer_groups
    def index
      @cluster = Cluster.find(params[:cluster_id])
      @groups = @cluster.groups

      flash[:search] = params[:group_id]

      if params[:group_id].present?
        @groups = @groups.select do |g|
          regex = /#{params[:group_id]}/i
          g.group_id.match?(regex)
        end
      end

      render_success(@groups)
    end

    # GET /alusters/:cluster_id/consumer_groups/:id
    def show
      @cluster = Cluster.find(params[:cluster_id])
      @group = @cluster.groups.find { |g| g.group_id == params[:id] }

      if @group.nil?
        render_error('Consumer group not found', status: 404)
        return
      end

      @current_topic =
        if params[:topic]
          @group.consumed_topics.find { |t| t.name == params[:topic] }
        else
          @group.consumed_topics.first
        end

      render_success(@group)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kafka_command-0.0.3 app/controllers/kafka_command/consumer_groups_controller.rb
kafka_command-0.0.2 app/controllers/kafka_command/consumer_groups_controller.rb
kafka_command-0.0.1 app/controllers/kafka_command/consumer_groups_controller.rb