module Api
  module V1
    NdcIndicators = Struct.new(:indicators, :categories) do
      alias_method :read_attribute_for_serialization, :send
    end

    class NdcsController < ApiController
      def index
        indicators = ::CaitIndc::Indicator.
          includes(
            :labels,
            :category,
            values: [:label, :location]
          )

        categories = ::CaitIndc::Category.all

        render json: NdcIndicators.new(indicators, categories),
               serializer: Api::V1::CaitIndc::NdcIndicatorsSerializer
      end
    end
  end
end

module Api
  module V1
    NdcIndicators = Struct.new(:indicators, :categories) do
      alias_method :read_attribute_for_serialization, :send
    end

    class NdcsController < ApiController
      def index
        indicators = ::CaitIndc::Indicator.
          includes(
            :labels,
            :category,
            values: [:label, :location]
          )

        if location_list
          indicators = indicators.where(
            values: { locations: { iso_code3: location_list } }
          )
        end

        if params[:filter] == 'map'
          indicators = indicators.where(on_map: true)
        end

        if params[:filter] == 'summary'
          indicators = indicators.where(summary_list: true)
        end

        categories = ::CaitIndc::Category.all

        render json: NdcIndicators.new(indicators, categories),
               serializer: Api::V1::CaitIndc::NdcIndicatorsSerializer
      end

      private

      def location_list
        params[:location].blank? ?
          nil :
          params[:location].split(',')
      end

    end
  end
end

Add filters to `/ndcs` endpoint
Add filters to `/ndcs` endpoint

`location` will take a comma-separated list of ISO3 values: `?location=AFG,CHN`
`filter` will take either `map` or `summary` as a parameter, and it will
retrieve indicators that are to be rendered on the map or on the summary screen.
