'Purges old push actions for a user and room before a given
topological_ordering.
We however keep a months worth of highlighted notifications, so that
users can still get a list of recent highlights.
Args:
txn: The transcation
room_id: Room ID to delete from
user_id: user ID to delete for
topological_ordering: The lowest topological ordering which will
not be deleted.'

def _remove_old_push_actions_before_txn(self, txn, room_id, user_id, topological_ordering, stream_ordering):

    txn.call_after(self.get_unread_event_push_actions_by_room_for_user.invalidate_many, (room_id, user_id))
    txn.execute('DELETE    FROM    event_push_actions        WHERE    user_id    =    ?    AND    room_id    =    ?    AND        topological_ordering    <=    ?    AND    ((stream_ordering    <    ?    AND    highlight    =    1)    or    highlight    =    0)', (user_id, room_id, topological_ordering, self.stream_ordering_month_ago))
    txn.execute('\n                                                DELETE    FROM    event_push_summary\n                                                WHERE    room_id    =    ?    AND    user_id    =    ?    AND    stream_ordering    <=    ?\n                                ', (room_id, user_id, stream_ordering))
