Use register_background_index_update
This commit is contained in:
parent
0294c14ec4
commit
7cd6edb947
|
@ -33,9 +33,11 @@ class EventPushActionsStore(SQLBaseStore):
|
|||
self.stream_ordering_month_ago = None
|
||||
super(EventPushActionsStore, self).__init__(hs)
|
||||
|
||||
self.register_background_update_handler(
|
||||
self.register_background_index_update(
|
||||
self.EPA_HIGHLIGHT_INDEX,
|
||||
self._background_index_epa_highlight,
|
||||
index_name="event_push_actions_u_highlight",
|
||||
table="event_push_actions",
|
||||
columns=["user_id", "highlight", "stream_ordering"],
|
||||
)
|
||||
|
||||
def _set_push_actions_for_event_and_users_txn(self, txn, event, tuples):
|
||||
|
@ -508,28 +510,6 @@ class EventPushActionsStore(SQLBaseStore):
|
|||
|
||||
return range_end
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _background_index_epa_highlight(self, progress, batch_size):
|
||||
def reindex_txn(txn):
|
||||
if isinstance(self.database_engine, PostgresEngine):
|
||||
txn.execute(
|
||||
"CREATE INDEX CONCURRENTLY event_push_actions_u_highlight"
|
||||
" on event_push_actions(user_id, highlight, stream_ordering)"
|
||||
)
|
||||
else:
|
||||
txn.execute(
|
||||
"CREATE INDEX event_push_actions_u_highlight"
|
||||
" on event_push_actions(user_id, highlight, stream_ordering)"
|
||||
)
|
||||
|
||||
yield self.runInteraction(
|
||||
self.EPA_HIGHLIGHT_INDEX, reindex_txn
|
||||
)
|
||||
|
||||
yield self._end_background_update(self.EPA_HIGHLIGHT_INDEX)
|
||||
|
||||
defer.returnValue(1)
|
||||
|
||||
|
||||
def _action_has_highlight(actions):
|
||||
for action in actions:
|
||||
|
|
Loading…
Reference in New Issue