mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-17 04:44:23 -05:00
Attempt to annotate events_forward_extremities (#11314)
* Make DataStore inherit from EventForwardExtremitiesStore before CacheInvalidationWorkerStore the former implicitly inherits from the latter, so they should be ordered like this when used.
This commit is contained in:
parent
4c96ce396e
commit
6f8f3d4bc5
1
changelog.d/11314.misc
Normal file
1
changelog.d/11314.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add type hints to storage classes.
|
1
mypy.ini
1
mypy.ini
@ -34,7 +34,6 @@ exclude = (?x)
|
|||||||
|synapse/storage/databases/main/event_federation.py
|
|synapse/storage/databases/main/event_federation.py
|
||||||
|synapse/storage/databases/main/event_push_actions.py
|
|synapse/storage/databases/main/event_push_actions.py
|
||||||
|synapse/storage/databases/main/events_bg_updates.py
|
|synapse/storage/databases/main/events_bg_updates.py
|
||||||
|synapse/storage/databases/main/events_forward_extremities.py
|
|
||||||
|synapse/storage/databases/main/events_worker.py
|
|synapse/storage/databases/main/events_worker.py
|
||||||
|synapse/storage/databases/main/group_server.py
|
|synapse/storage/databases/main/group_server.py
|
||||||
|synapse/storage/databases/main/media_repository.py
|
|synapse/storage/databases/main/media_repository.py
|
||||||
|
@ -123,9 +123,9 @@ class DataStore(
|
|||||||
RelationsStore,
|
RelationsStore,
|
||||||
CensorEventsStore,
|
CensorEventsStore,
|
||||||
UIAuthStore,
|
UIAuthStore,
|
||||||
|
EventForwardExtremitiesStore,
|
||||||
CacheInvalidationWorkerStore,
|
CacheInvalidationWorkerStore,
|
||||||
ServerMetricsStore,
|
ServerMetricsStore,
|
||||||
EventForwardExtremitiesStore,
|
|
||||||
LockStore,
|
LockStore,
|
||||||
SessionStore,
|
SessionStore,
|
||||||
):
|
):
|
||||||
|
@ -13,15 +13,20 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from synapse.api.errors import SynapseError
|
from synapse.api.errors import SynapseError
|
||||||
from synapse.storage._base import SQLBaseStore
|
from synapse.storage.database import LoggingTransaction
|
||||||
|
from synapse.storage.databases.main import CacheInvalidationWorkerStore
|
||||||
|
from synapse.storage.databases.main.event_federation import EventFederationWorkerStore
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EventForwardExtremitiesStore(SQLBaseStore):
|
class EventForwardExtremitiesStore(
|
||||||
|
EventFederationWorkerStore,
|
||||||
|
CacheInvalidationWorkerStore,
|
||||||
|
):
|
||||||
async def delete_forward_extremities_for_room(self, room_id: str) -> int:
|
async def delete_forward_extremities_for_room(self, room_id: str) -> int:
|
||||||
"""Delete any extra forward extremities for a room.
|
"""Delete any extra forward extremities for a room.
|
||||||
|
|
||||||
@ -31,7 +36,7 @@ class EventForwardExtremitiesStore(SQLBaseStore):
|
|||||||
Returns count deleted.
|
Returns count deleted.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def delete_forward_extremities_for_room_txn(txn):
|
def delete_forward_extremities_for_room_txn(txn: LoggingTransaction) -> int:
|
||||||
# First we need to get the event_id to not delete
|
# First we need to get the event_id to not delete
|
||||||
sql = """
|
sql = """
|
||||||
SELECT event_id FROM event_forward_extremities
|
SELECT event_id FROM event_forward_extremities
|
||||||
@ -82,10 +87,14 @@ class EventForwardExtremitiesStore(SQLBaseStore):
|
|||||||
delete_forward_extremities_for_room_txn,
|
delete_forward_extremities_for_room_txn,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_forward_extremities_for_room(self, room_id: str) -> List[Dict]:
|
async def get_forward_extremities_for_room(
|
||||||
|
self, room_id: str
|
||||||
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get list of forward extremities for a room."""
|
"""Get list of forward extremities for a room."""
|
||||||
|
|
||||||
def get_forward_extremities_for_room_txn(txn):
|
def get_forward_extremities_for_room_txn(
|
||||||
|
txn: LoggingTransaction,
|
||||||
|
) -> List[Dict[str, Any]]:
|
||||||
sql = """
|
sql = """
|
||||||
SELECT event_id, state_group, depth, received_ts
|
SELECT event_id, state_group, depth, received_ts
|
||||||
FROM event_forward_extremities
|
FROM event_forward_extremities
|
||||||
|
Loading…
Reference in New Issue
Block a user