Fix geocoding and add a pause option
This commit is contained in:
parent
0044bc4b3c
commit
ffa8829c3e
2 changed files with 17 additions and 2 deletions
|
@ -28,7 +28,9 @@ def add_countries():
|
|||
return
|
||||
database.connect()
|
||||
with database.atomic():
|
||||
q = Change.select().where((Change.country >> None) & (Change.action != 'a') & (~Change.changes.startswith('[[null, null]'))).limit(config.GEOCODE_BATCH)
|
||||
q = Change.select().where((Change.country >> None) & (Change.action != 'a') & (~Change.changes.startswith('[[null, null]'))).limit(
|
||||
config.GEOCODE_BATCH + 200)
|
||||
count = config.GEOCODE_BATCH
|
||||
for ch in q:
|
||||
coord = ch.changed_coord()
|
||||
if coord is not None:
|
||||
|
@ -37,7 +39,13 @@ def add_countries():
|
|||
ch.country = country[:150]
|
||||
ch.save()
|
||||
else:
|
||||
print('Empty coordinates: {0} {1} {2}'.format(ch.id, ch.action, ch.changes.encode('utf-8')))
|
||||
# print('Empty coordinates: {0} {1} {2}'.format(ch.id, ch.action, ch.changes.encode('utf-8')))
|
||||
pass
|
||||
|
||||
# We request more because of these empty coordinates errors
|
||||
count -= 1
|
||||
if count <= 0:
|
||||
break
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -75,9 +75,16 @@ def purl(params, **kwargs):
|
|||
return url_for('the_one_and_only_page', **p2)
|
||||
|
||||
|
||||
def is_disabled():
|
||||
return os.path.exists(os.path.join(config.BASE_DIR, 'pause'))
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@cached()
|
||||
def the_one_and_only_page():
|
||||
if is_disabled():
|
||||
return "The service is disabled for updates.<br>Please come back in a couple minutes."
|
||||
|
||||
# Parse query params
|
||||
params = {}
|
||||
page = request.args.get('page', '1')
|
||||
|
|
Loading…
Add table
Reference in a new issue