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



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/karafka/web/pro/ui/lib/search/normalizer.rb', line 29

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