Skip to content

Commit

Permalink
Fixes bug with custom settings (#28)
Browse files Browse the repository at this point in the history
* Fixes bug with custom settings

* remove unecessary duplicate
  • Loading branch information
bidoubiwa authored Jun 10, 2020
1 parent 1fd65c8 commit f5c6b64
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scraper/src/config/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConfigLoader:
allowed_domains = None
api_key = None
app_id = None
custom_settings = None
custom_settings = {}
extra_records = []
index_uid = None
index_uid_tmp = None
Expand Down
6 changes: 4 additions & 2 deletions scraper/src/meilisearch_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ class MeiliSearchHelper:

def __init__(self, host_url, api_key, index_uid, custom_settings):
self.meilisearch_client = meilisearch.Client(host_url, api_key)
self.__delete_and_create_index(index_uid)
self.meilisearch_index = self.__delete_and_create_index(index_uid)
settings = {**MeiliSearchHelper.SETTINGS, **custom_settings}
self.add_settings(MeiliSearchHelper.SETTINGS, custom_settings)

def add_settings(self, default_settings, custom_settings):
settings = {**default_settings, **custom_settings}
self.meilisearch_index.update_settings(settings)

def add_records(self, records, url, from_sitemap):
Expand Down
2 changes: 1 addition & 1 deletion scraper/src/tests/config_loader/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def config(additional_config={}):
'allowed_domains': 'allowed_domains',
'api_key': 'api_key',
'app_id': 'app_id',
'custom_settings': {},
'custom_settings': None,
'hash_strategy': 'hash_strategy',
'index_uid': 'index_uid',
'selectors': [],
Expand Down

0 comments on commit f5c6b64

Please sign in to comment.