module Jekyll::Algolia::Shrinker
def self.stop_with_error(record)
This will display an error message and log the wrong record in a file in
- record: The record causing the error
record that is too big to be pushed
Public: Stop the current indexing process and display details about the
def self.stop_with_error(record) record_size = size(record) record_size_readable = Filesize.from("#{record_size}B").to_s('Kb') max_record_size = Configurator.algolia('max_record_size') max_record_size_readable = Filesize .from("#{max_record_size}B").to_s('Kb') probable_wrong_keys = readable_largest_record_keys(record) # Writing the full record to disk for inspection record_log_path = Logger.write_to_file( 'jekyll-algolia-record-too-big.log', JSON.pretty_generate(record) ) details = { 'object_title' => record[:title], 'object_url' => record[:url], 'probable_wrong_keys' => probable_wrong_keys, 'record_log_path' => record_log_path, 'nodes_to_index' => Configurator.algolia('nodes_to_index'), 'record_size' => record_size_readable, 'max_record_size' => max_record_size_readable } Logger.known_message('record_too_big', details) stop_process end