6
6
"""
7
7
8
8
from collections import OrderedDict
9
+ from distutils .util import strtobool
9
10
import json
10
11
import os
11
12
import copy
@@ -49,6 +50,7 @@ class ConfigLoader(object):
49
50
strategy = 'default'
50
51
strict_redirect = True
51
52
strip_chars = u".,;:§¶"
53
+ update_nb_hits = None
52
54
use_anchors = False
53
55
user_agent = 'Algolia DocSearch Crawler'
54
56
only_content_level = False
@@ -112,6 +114,9 @@ def _parse(self):
112
114
# Parse Env
113
115
self .app_id = os .environ .get ('APPLICATION_ID' , None )
114
116
self .api_key = os .environ .get ('API_KEY' , None )
117
+ self .update_nb_hits = os .environ .get ('UPDATE_NB_HITS' , None )
118
+ if self .update_nb_hits is not None :
119
+ self .update_nb_hits = bool (strtobool (self .update_nb_hits ))
115
120
116
121
# Parse config
117
122
self .selectors = SelectorsParser ().parse (self .selectors )
@@ -124,15 +129,15 @@ def _parse(self):
124
129
self .allowed_domains = UrlsParser .build_allowed_domains (
125
130
self .start_urls , self .stop_urls )
126
131
127
- def update_nb_hits (self , nb_hits ):
132
+ def update_nb_hits_value (self , nb_hits ):
128
133
if self .config_file is not None :
129
134
# config loaded from file
130
135
previous_nb_hits = None if 'nb_hits' not in self .config_content else \
131
136
self .config_content ['nb_hits' ]
132
137
nb_hit_updater = NbHitsUpdater (self .config_file ,
133
138
self .config_content ,
134
139
previous_nb_hits , nb_hits )
135
- nb_hit_updater .update ()
140
+ nb_hit_updater .update (self . update_nb_hits )
136
141
137
142
def get_extra_facets (self ):
138
143
return UrlsParser .get_extra_facets (self .start_urls )
0 commit comments