Skip to content
Snippets Groups Projects
Commit 27facad9 authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

Added missing indices to recreate procedure. Some indent fixes

parent fb00babb
No related branches found
No related tags found
5 merge requests!456Release candidate v1 24,!261Mi livesync hot and trends2,!249Mi hot and trends livesync,!237Mi empty result for unread notification,!184Speedup proposal for `list_comments`
This commit is part of merge request !184. Comments created here will be created in the context of that merge request.
...@@ -110,6 +110,8 @@ class DbState: ...@@ -110,6 +110,8 @@ class DbState:
'hive_posts_sc_trend_idx', 'hive_posts_sc_trend_idx',
'hive_posts_sc_hot_idx', 'hive_posts_sc_hot_idx',
'hive_posts_block_num_idx', 'hive_posts_block_num_idx',
'hive_posts_cashout_time_idx',
'hive_posts_updated_at_idx',
'hive_votes_post_id_idx', 'hive_votes_post_id_idx',
'hive_votes_voter_id_idx', 'hive_votes_voter_id_idx',
...@@ -141,23 +143,23 @@ class DbState: ...@@ -141,23 +143,23 @@ class DbState:
@classmethod @classmethod
def processing_indexes(cls, is_pre_process, drop, create ): def processing_indexes(cls, is_pre_process, drop, create ):
DB = cls.db() DB = cls.db()
engine = DB.engine() engine = DB.engine()
log.info("[INIT] Begin %s-initial sync hooks", "pre" if is_pre_process else "post" ) log.info("[INIT] Begin %s-initial sync hooks", "pre" if is_pre_process else "post")
for index in cls._disableable_indexes(): for index in cls._disableable_indexes():
log.info("%s index %s.%s", ( "Drop" if is_pre_process else "Recreate" ), index.table, index.name) log.info("%s index %s.%s", ("Drop" if is_pre_process else "Recreate"), index.table, index.name)
try: try:
if drop: if drop:
sql = "SELECT count(*) FROM pg_class WHERE relname = :relname" sql = "SELECT count(*) FROM pg_class WHERE relname = :relname"
_count = DB.query_one(sql, relname=index.name) _count = DB.query_one(sql, relname=index.name)
if _count == 1: if _count == 1:
index.drop(engine) index.drop(engine)
except sqlalchemy.exc.ProgrammingError as ex: except sqlalchemy.exc.ProgrammingError as ex:
log.warning("Ignoring ex: {}".format(ex)) log.warning("Ignoring ex: {}".format(ex))
if create: if create:
index.create(engine) index.create(engine)
@classmethod @classmethod
def before_initial_sync(cls, last_imported_block, hived_head_block): def before_initial_sync(cls, last_imported_block, hived_head_block):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment