Create the index in a background update
parent
5283f65316
commit
26a27e06b9
|
|
@ -19,12 +19,12 @@ from twisted.internet import defer
|
|||
from synapse.api.errors import StoreError
|
||||
from synapse.storage.roommember import ProfileInfo
|
||||
|
||||
from ._base import SQLBaseStore
|
||||
from . import background_updates
|
||||
|
||||
BATCH_SIZE = 100
|
||||
|
||||
|
||||
class ProfileWorkerStore(SQLBaseStore):
|
||||
class ProfileWorkerStore(background_updates.BackgroundUpdateStore):
|
||||
@defer.inlineCallbacks
|
||||
def get_profileinfo(self, user_localpart):
|
||||
try:
|
||||
|
|
@ -166,6 +166,17 @@ class ProfileWorkerStore(SQLBaseStore):
|
|||
|
||||
|
||||
class ProfileStore(ProfileWorkerStore):
|
||||
def __init__(self, db_conn, hs):
|
||||
|
||||
super(ProfileStore, self).__init__(db_conn, hs)
|
||||
|
||||
self.register_background_index_update(
|
||||
"profile_replication_status_host_index",
|
||||
index_name="profile_replication_status_idx",
|
||||
table="profile_replication_status",
|
||||
columns=["host"],
|
||||
)
|
||||
|
||||
def add_remote_profile_cache(self, user_id, displayname, avatar_url):
|
||||
"""Ensure we are caching the remote user's profiles.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
CREATE UNIQUE INDEX profile_replication_status_idx ON profile_replication_status(host);
|
||||
INSERT INTO background_updates (update_name, progress_json) VALUES
|
||||
('profile_replication_status_host_index', '{}');
|
||||
Loading…
Reference in New Issue