1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 09:10:00 +00:00

fix broken import_to_es.py

This commit is contained in:
nyaadev 2017-09-17 02:54:09 +02:00
parent c5d705210d
commit 1bc21bc599

View file

@ -98,34 +98,34 @@ FLAVORS = [
with app.app_context(): with app.app_context():
master_status = db.engine.execute('SHOW MASTER STATUS;').fetchone() master_status = db.engine.execute('SHOW MASTER STATUS;').fetchone()
position_json = { position_json = {
'log_file': master_status[0], 'log_file': master_status[0],
'log_pos': master_status[1] 'log_pos': master_status[1]
} }
print('Save the following in the file configured in your ES sync config JSON:') print('Save the following in the file configured in your ES sync config JSON:')
print(json.dumps(position_json)) print(json.dumps(position_json))
for flavor, torrent_class in FLAVORS: for flavor, torrent_class in FLAVORS:
print('Importing torrents for index', flavor, 'from', torrent_class) print('Importing torrents for index', flavor, 'from', torrent_class)
bar = progressbar.ProgressBar( bar = progressbar.ProgressBar(
maxval=torrent_class.query.count(), maxval=torrent_class.query.count(),
widgets=[ progressbar.SimpleProgress(), widgets=[ progressbar.SimpleProgress(),
' [', progressbar.Timer(), '] ', ' [', progressbar.Timer(), '] ',
progressbar.Bar(), progressbar.Bar(),
' (', progressbar.ETA(), ') ', ' (', progressbar.ETA(), ') ',
]) ])
# turn off refreshes while bulk loading # turn off refreshes while bulk loading
ic.put_settings(body={'index': {'refresh_interval': '-1'}}, index=flavor) ic.put_settings(body={'index': {'refresh_interval': '-1'}}, index=flavor)
bar.start() bar.start()
helpers.bulk(es, (mk_es(t, flavor) for t in page_query(torrent_class.query, progress_bar=bar)), chunk_size=10000) helpers.bulk(es, (mk_es(t, flavor) for t in page_query(torrent_class.query, progress_bar=bar)), chunk_size=10000)
bar.finish() bar.finish()
# Refresh the index immideately # Refresh the index immideately
ic.refresh(index=flavor) ic.refresh(index=flavor)
print('Index refresh done.') print('Index refresh done.')
# restore to near-enough real time # restore to near-enough real time
ic.put_settings(body={'index': {'refresh_interval': '30s'}}, index=flavor) ic.put_settings(body={'index': {'refresh_interval': '30s'}}, index=flavor)