Module: Karafka::Web::Pro::Ui::Lib::Search::Normalizer

Defined in:
lib/karafka/web/pro/ui/lib/search/normalizer.rb

Overview

Takes basic search parameters and normalizes the data a bit Since we have fairly simple search input argument types, we can cast them easily into format that we can accept further down the pipeline. This module provides this normalization, so we do not have to worry about weird edge cases.

Class Method Summary collapse

Class Method Details

.call(search_query) ⇒ Hash

Returns normalized search query hash.

Parameters:

  • search_query (Hash)

    hash with expected data

Returns:

  • (Hash)

    normalized search query hash



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/karafka/web/pro/ui/lib/search/normalizer.rb', line 21

def call(search_query)
  {
    phrase: search_query['phrase'].to_s,
    limit: search_query['limit'].to_i,
    matcher: search_query['matcher'].to_s,
    partitions: Array(search_query['partitions']).flatten.compact.uniq,
    offset_type: search_query['offset_type'].to_s,
    timestamp: search_query['timestamp'].to_i,
    offset: search_query['offset'].to_i
  }
end