Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7055 from matrix-org/babolivier/get_time_of_last_…
Browse files Browse the repository at this point in the history
…push_action_before

* commit '14b2ebe76':
  Changelog
  Fix undefined `room_id` in `make_summary_text`
  Move `get_time_of_last_push_action_before` to the `EventPushActionsWorkerStore`
  • Loading branch information
anoadragon453 committed Mar 24, 2020
2 parents cae4284 + 14b2ebe commit 42e1eef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions changelog.d/7055.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Merge worker apps together.
4 changes: 3 additions & 1 deletion synapse/push/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,12 @@ def make_summary_text(
else:
# If the reason room doesn't have a name, say who the messages
# are from explicitly to avoid, "messages in the Bob room"
room_id = reason["room_id"]

sender_ids = list(
{
notif_events[n["event_id"]].sender
for n in notifs_by_room[reason["room_id"]]
for n in notifs_by_room[room_id]
}
)

Expand Down
34 changes: 17 additions & 17 deletions synapse/storage/data_stores/main/event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,23 @@ def _find_first_stream_ordering_after_ts_txn(txn, ts):

return range_end

@defer.inlineCallbacks
def get_time_of_last_push_action_before(self, stream_ordering):
def f(txn):
sql = (
"SELECT e.received_ts"
" FROM event_push_actions AS ep"
" JOIN events e ON ep.room_id = e.room_id AND ep.event_id = e.event_id"
" WHERE ep.stream_ordering > ?"
" ORDER BY ep.stream_ordering ASC"
" LIMIT 1"
)
txn.execute(sql, (stream_ordering,))
return txn.fetchone()

result = yield self.db.runInteraction("get_time_of_last_push_action_before", f)
return result[0] if result else None


class EventPushActionsStore(EventPushActionsWorkerStore):
EPA_HIGHLIGHT_INDEX = "epa_highlight_index"
Expand Down Expand Up @@ -735,23 +752,6 @@ def f(txn):
pa["actions"] = _deserialize_action(pa["actions"], pa["highlight"])
return push_actions

@defer.inlineCallbacks
def get_time_of_last_push_action_before(self, stream_ordering):
def f(txn):
sql = (
"SELECT e.received_ts"
" FROM event_push_actions AS ep"
" JOIN events e ON ep.room_id = e.room_id AND ep.event_id = e.event_id"
" WHERE ep.stream_ordering > ?"
" ORDER BY ep.stream_ordering ASC"
" LIMIT 1"
)
txn.execute(sql, (stream_ordering,))
return txn.fetchone()

result = yield self.db.runInteraction("get_time_of_last_push_action_before", f)
return result[0] if result else None

@defer.inlineCallbacks
def get_latest_push_action_stream_ordering(self):
def f(txn):
Expand Down

0 comments on commit 42e1eef

Please sign in to comment.