diff --git a/synapse/storage/data_stores/main/profile.py b/synapse/storage/data_stores/main/profile.py
index efef6f1fa6..8ab67a6b91 100644
--- a/synapse/storage/data_stores/main/profile.py
+++ b/synapse/storage/data_stores/main/profile.py
@@ -29,7 +29,7 @@ class ProfileWorkerStore(SQLBaseStore):
@defer.inlineCallbacks
def get_profileinfo(self, user_localpart):
try:
- profile = yield self.simple_select_one(
+ profile = yield self.db.simple_select_one(
table="profiles",
keyvalues={"user_id": user_localpart},
retcols=("displayname", "avatar_url"),
@@ -47,7 +47,7 @@ class ProfileWorkerStore(SQLBaseStore):
)
def get_profile_displayname(self, user_localpart):
- return self.simple_select_one_onecol(
+ return self.db.simple_select_one_onecol(
table="profiles",
keyvalues={"user_id": user_localpart},
retcol="displayname",
@@ -55,7 +55,7 @@ class ProfileWorkerStore(SQLBaseStore):
)
def get_profile_avatar_url(self, user_localpart):
- return self.simple_select_one_onecol(
+ return self.db.simple_select_one_onecol(
table="profiles",
keyvalues={"user_id": user_localpart},
retcol="avatar_url",
@@ -65,13 +65,13 @@ class ProfileWorkerStore(SQLBaseStore):
def get_latest_profile_replication_batch_number(self):
def f(txn):
txn.execute("SELECT MAX(batch) as maxbatch FROM profiles")
- rows = self.cursor_to_dict(txn)
+ rows = self.db.cursor_to_dict(txn)
return rows[0]["maxbatch"]
- return self.runInteraction("get_latest_profile_replication_batch_number", f)
+ return self.db.runInteraction("get_latest_profile_replication_batch_number", f)
def get_profile_batch(self, batchnum):
- return self.simple_select_list(
+ return self.db.simple_select_list(
table="profiles",
keyvalues={"batch": batchnum},
retcols=("user_id", "displayname", "avatar_url", "active"),
@@ -90,20 +90,20 @@ class ProfileWorkerStore(SQLBaseStore):
txn.execute(sql, (BATCH_SIZE,))
return txn.rowcount
- return self.runInteraction("assign_profile_batch", f)
+ return self.db.runInteraction("assign_profile_batch", f)
def get_replication_hosts(self):
def f(txn):
txn.execute(
"SELECT host, last_synced_batch FROM profile_replication_status"
)
- rows = self.cursor_to_dict(txn)
+ rows = self.db.cursor_to_dict(txn)
return {r["host"]: r["last_synced_batch"] for r in rows}
- return self.runInteraction("get_replication_hosts", f)
+ return self.db.runInteraction("get_replication_hosts", f)
def update_replication_batch_for_host(self, host, last_synced_batch):
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="profile_replication_status",
keyvalues={"host": host},
values={"last_synced_batch": last_synced_batch},
@@ -111,7 +111,7 @@ class ProfileWorkerStore(SQLBaseStore):
)
def get_from_remote_profile_cache(self, user_id):
- return self.simple_select_one(
+ return self.db.simple_select_one(
table="remote_profile_cache",
keyvalues={"user_id": user_id},
retcols=("displayname", "avatar_url"),
@@ -120,12 +120,12 @@ class ProfileWorkerStore(SQLBaseStore):
)
def create_profile(self, user_localpart):
- return self.simple_insert(
+ return self.db.simple_insert(
table="profiles", values={"user_id": user_localpart}, desc="create_profile"
)
def set_profile_displayname(self, user_localpart, new_displayname, batchnum):
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="profiles",
keyvalues={"user_id": user_localpart},
values={"displayname": new_displayname, "batch": batchnum},
@@ -134,7 +134,7 @@ class ProfileWorkerStore(SQLBaseStore):
)
def set_profile_avatar_url(self, user_localpart, new_avatar_url, batchnum):
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="profiles",
keyvalues={"user_id": user_localpart},
values={"avatar_url": new_avatar_url, "batch": batchnum},
@@ -149,7 +149,7 @@ class ProfileWorkerStore(SQLBaseStore):
# so clear the profile.
values["avatar_url"] = None
values["displayname"] = None
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="profiles",
keyvalues={"user_id": user_localpart},
values=values,
@@ -158,12 +158,12 @@ class ProfileWorkerStore(SQLBaseStore):
)
-class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore):
+class ProfileStore(ProfileWorkerStore):
def __init__(self, db_conn, hs):
super(ProfileStore, self).__init__(db_conn, hs)
- self.register_background_index_update(
+ self.db.updates.register_background_index_update(
"profile_replication_status_host_index",
index_name="profile_replication_status_idx",
table="profile_replication_status",
@@ -177,7 +177,7 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
This should only be called when `is_subscribed_remote_profile_for_user`
would return true for the user.
"""
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="remote_profile_cache",
keyvalues={"user_id": user_id},
values={
@@ -189,7 +189,7 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
)
def update_remote_profile_cache(self, user_id, displayname, avatar_url):
- return self.simple_upsert(
+ return self.db.simple_upsert(
table="remote_profile_cache",
keyvalues={"user_id": user_id},
values={
@@ -207,7 +207,7 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
"""
subscribed = yield self.is_subscribed_remote_profile_for_user(user_id)
if not subscribed:
- yield self.simple_delete(
+ yield self.db.simple_delete(
table="remote_profile_cache",
keyvalues={"user_id": user_id},
desc="delete_remote_profile_cache",
@@ -226,9 +226,9 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
txn.execute(sql, (last_checked,))
- return self.cursor_to_dict(txn)
+ return self.db.cursor_to_dict(txn)
- return self.runInteraction(
+ return self.db.runInteraction(
"get_remote_profile_cache_entries_that_expire",
_get_remote_profile_cache_entries_that_expire_txn,
)
@@ -237,7 +237,7 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
def is_subscribed_remote_profile_for_user(self, user_id):
"""Check whether we are interested in a remote user's profile.
"""
- res = yield self.simple_select_one_onecol(
+ res = yield self.db.simple_select_one_onecol(
table="group_users",
keyvalues={"user_id": user_id},
retcol="user_id",
@@ -248,7 +248,7 @@ class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore)
if res:
return True
- res = yield self.simple_select_one_onecol(
+ res = yield self.db.simple_select_one_onecol(
table="group_invites",
keyvalues={"user_id": user_id},
retcol="user_id",
|