mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 14:20:23 +00:00
Measure _get_event_from_row
This commit is contained in:
parent
2426c2f21a
commit
47dd8f02a1
1 changed files with 44 additions and 42 deletions
|
@ -22,6 +22,7 @@ from synapse.events.utils import prune_event
|
||||||
from synapse.util.async import ObservableDeferred
|
from synapse.util.async import ObservableDeferred
|
||||||
from synapse.util.logcontext import preserve_fn, PreserveLoggingContext
|
from synapse.util.logcontext import preserve_fn, PreserveLoggingContext
|
||||||
from synapse.util.logutils import log_function
|
from synapse.util.logutils import log_function
|
||||||
|
from synapse.util.metrics import Measure
|
||||||
from synapse.api.constants import EventTypes
|
from synapse.api.constants import EventTypes
|
||||||
from synapse.api.errors import SynapseError
|
from synapse.api.errors import SynapseError
|
||||||
|
|
||||||
|
@ -1132,56 +1133,57 @@ class EventsStore(SQLBaseStore):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get_event_from_row(self, internal_metadata, js, redacted,
|
def _get_event_from_row(self, internal_metadata, js, redacted,
|
||||||
rejected_reason=None):
|
rejected_reason=None):
|
||||||
d = json.loads(js)
|
with Measure(self._clock, "_get_event_from_row"):
|
||||||
internal_metadata = json.loads(internal_metadata)
|
d = json.loads(js)
|
||||||
|
internal_metadata = json.loads(internal_metadata)
|
||||||
|
|
||||||
if rejected_reason:
|
if rejected_reason:
|
||||||
rejected_reason = yield self._simple_select_one_onecol(
|
rejected_reason = yield self._simple_select_one_onecol(
|
||||||
table="rejections",
|
table="rejections",
|
||||||
keyvalues={"event_id": rejected_reason},
|
keyvalues={"event_id": rejected_reason},
|
||||||
retcol="reason",
|
retcol="reason",
|
||||||
desc="_get_event_from_row_rejected_reason",
|
desc="_get_event_from_row_rejected_reason",
|
||||||
|
)
|
||||||
|
|
||||||
|
original_ev = FrozenEvent(
|
||||||
|
d,
|
||||||
|
internal_metadata_dict=internal_metadata,
|
||||||
|
rejected_reason=rejected_reason,
|
||||||
)
|
)
|
||||||
|
|
||||||
original_ev = FrozenEvent(
|
redacted_event = None
|
||||||
d,
|
if redacted:
|
||||||
internal_metadata_dict=internal_metadata,
|
redacted_event = prune_event(original_ev)
|
||||||
rejected_reason=rejected_reason,
|
|
||||||
)
|
|
||||||
|
|
||||||
redacted_event = None
|
redaction_id = yield self._simple_select_one_onecol(
|
||||||
if redacted:
|
table="redactions",
|
||||||
redacted_event = prune_event(original_ev)
|
keyvalues={"redacts": redacted_event.event_id},
|
||||||
|
retcol="event_id",
|
||||||
|
desc="_get_event_from_row_redactions",
|
||||||
|
)
|
||||||
|
|
||||||
redaction_id = yield self._simple_select_one_onecol(
|
redacted_event.unsigned["redacted_by"] = redaction_id
|
||||||
table="redactions",
|
# Get the redaction event.
|
||||||
keyvalues={"redacts": redacted_event.event_id},
|
|
||||||
retcol="event_id",
|
because = yield self.get_event(
|
||||||
desc="_get_event_from_row_redactions",
|
redaction_id,
|
||||||
|
check_redacted=False,
|
||||||
|
allow_none=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
if because:
|
||||||
|
# It's fine to do add the event directly, since get_pdu_json
|
||||||
|
# will serialise this field correctly
|
||||||
|
redacted_event.unsigned["redacted_because"] = because
|
||||||
|
|
||||||
|
cache_entry = _EventCacheEntry(
|
||||||
|
event=original_ev,
|
||||||
|
redacted_event=redacted_event,
|
||||||
)
|
)
|
||||||
|
|
||||||
redacted_event.unsigned["redacted_by"] = redaction_id
|
self._get_event_cache.prefill((original_ev.event_id,), cache_entry)
|
||||||
# Get the redaction event.
|
|
||||||
|
|
||||||
because = yield self.get_event(
|
defer.returnValue(cache_entry)
|
||||||
redaction_id,
|
|
||||||
check_redacted=False,
|
|
||||||
allow_none=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
if because:
|
|
||||||
# It's fine to do add the event directly, since get_pdu_json
|
|
||||||
# will serialise this field correctly
|
|
||||||
redacted_event.unsigned["redacted_because"] = because
|
|
||||||
|
|
||||||
cache_entry = _EventCacheEntry(
|
|
||||||
event=original_ev,
|
|
||||||
redacted_event=redacted_event,
|
|
||||||
)
|
|
||||||
|
|
||||||
self._get_event_cache.prefill((original_ev.event_id,), cache_entry)
|
|
||||||
|
|
||||||
defer.returnValue(cache_entry)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def count_daily_messages(self):
|
def count_daily_messages(self):
|
||||||
|
|
Loading…
Reference in a new issue