refactor(index): End refactoring
This commit is contained in:
parent
30de69189b
commit
110425c00d
29
lib/push.rb
29
lib/push.rb
@ -167,27 +167,28 @@ class AlgoliaSearchJekyllPush < Jekyll::Command
|
|||||||
def push(items)
|
def push(items)
|
||||||
check_credentials
|
check_credentials
|
||||||
|
|
||||||
|
index_name = @config['algolia']['index_name']
|
||||||
Algolia.init(
|
Algolia.init(
|
||||||
application_id: @config['algolia']['application_id'],
|
application_id: @config['algolia']['application_id'],
|
||||||
api_key: api_key
|
api_key: api_key
|
||||||
)
|
)
|
||||||
index = Algolia::Index.new(@config['algolia']['index_name'])
|
index = Algolia::Index.new(index_name)
|
||||||
configure_index(index)
|
configure_index(index)
|
||||||
# index.clear_index
|
index.clear_index
|
||||||
|
|
||||||
# items.each_slice(1000) do |batch|
|
items.each_slice(1000) do |batch|
|
||||||
# Jekyll.logger.info "Indexing #{batch.size} items"
|
Jekyll.logger.info "Indexing #{batch.size} items"
|
||||||
# begin
|
begin
|
||||||
# index.add_objects(batch)
|
index.add_objects(batch)
|
||||||
# rescue StandardError => error
|
rescue StandardError => error
|
||||||
# Jekyll.logger.error 'Algolia Error: HTTP Error'
|
Jekyll.logger.error 'Algolia Error: HTTP Error'
|
||||||
# Jekyll.logger.warn error.message
|
Jekyll.logger.warn error.message
|
||||||
# exit 1
|
exit 1
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
# Jekyll.logger.info "Indexing of #{items.size} items " \
|
Jekyll.logger.info "Indexing of #{items.size} items " \
|
||||||
# "in #{index_name} done."
|
"in #{index_name} done."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -175,7 +175,7 @@ describe(AlgoliaSearchJekyllPush) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fdescribe 'configure_index' do
|
describe 'configure_index' do
|
||||||
it 'sets some sane defaults' do
|
it 'sets some sane defaults' do
|
||||||
# Given
|
# Given
|
||||||
push.init_options(nil, options, config)
|
push.init_options(nil, options, config)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user