mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Use a namedtuple rather than tuple unpacking
This commit is contained in:
parent
1fbb094c6f
commit
2ec5426035
@ -204,31 +204,27 @@ class ReplicationResource(Resource):
|
|||||||
request_events = current_token.events
|
request_events = current_token.events
|
||||||
if request_backfill is None:
|
if request_backfill is None:
|
||||||
request_backfill = current_token.backfill
|
request_backfill = current_token.backfill
|
||||||
(
|
res = yield self.store.get_all_new_events(
|
||||||
events_rows, backfill_rows,
|
|
||||||
forward_ex_outliers, backward_ex_outliers,
|
|
||||||
state_resets
|
|
||||||
) = yield self.store.get_all_new_events(
|
|
||||||
request_backfill, request_events,
|
request_backfill, request_events,
|
||||||
current_token.backfill, current_token.events,
|
current_token.backfill, current_token.events,
|
||||||
limit
|
limit
|
||||||
)
|
)
|
||||||
writer.write_header_and_rows("events", events_rows, (
|
writer.write_header_and_rows("events", res.new_forward_events, (
|
||||||
"position", "internal", "json", "state_group"
|
"position", "internal", "json", "state_group"
|
||||||
))
|
))
|
||||||
writer.write_header_and_rows("backfill", backfill_rows, (
|
writer.write_header_and_rows("backfill", res.new_backfill_events, (
|
||||||
"position", "internal", "json", "state_group"
|
"position", "internal", "json", "state_group"
|
||||||
))
|
))
|
||||||
writer.write_header_and_rows(
|
writer.write_header_and_rows(
|
||||||
"forward_ex_outliers", forward_ex_outliers,
|
"forward_ex_outliers", res.forward_ex_outliers,
|
||||||
("position", "event_id", "state_group")
|
("position", "event_id", "state_group")
|
||||||
)
|
)
|
||||||
writer.write_header_and_rows(
|
writer.write_header_and_rows(
|
||||||
"backward_ex_outliers", backward_ex_outliers,
|
"backward_ex_outliers", res.backward_ex_outliers,
|
||||||
("position", "event_id", "state_group")
|
("position", "event_id", "state_group")
|
||||||
)
|
)
|
||||||
writer.write_header_and_rows(
|
writer.write_header_and_rows(
|
||||||
"state_resets", state_resets, ("position",)
|
"state_resets", res.state_resets, ("position",)
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -25,7 +25,7 @@ from synapse.api.constants import EventTypes
|
|||||||
|
|
||||||
from canonicaljson import encode_canonical_json
|
from canonicaljson import encode_canonical_json
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
@ -1193,9 +1193,16 @@ class EventsStore(SQLBaseStore):
|
|||||||
new_backfill_events = []
|
new_backfill_events = []
|
||||||
backward_ex_outliers = []
|
backward_ex_outliers = []
|
||||||
|
|
||||||
return (
|
return AllNewEventsResult(
|
||||||
new_forward_events, new_backfill_events,
|
new_forward_events, new_backfill_events,
|
||||||
forward_ex_outliers, backward_ex_outliers,
|
forward_ex_outliers, backward_ex_outliers,
|
||||||
state_resets,
|
state_resets,
|
||||||
)
|
)
|
||||||
return self.runInteraction("get_all_new_events", get_all_new_events_txn)
|
return self.runInteraction("get_all_new_events", get_all_new_events_txn)
|
||||||
|
|
||||||
|
|
||||||
|
AllNewEventsResult = namedtuple("AllNewEventsResult", [
|
||||||
|
"new_forward_events", "new_backfill_events",
|
||||||
|
"forward_ex_outliers", "backward_ex_outliers",
|
||||||
|
"state_resets"
|
||||||
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user