

def get_oldest_events_with_depth_in_room_txn(self, txn, room_id):
    sql = 'SELECT b.event_id, MAX(e.depth) FROM events as e INNER JOIN event_edges as g ON g.event_id = e.event_id AND g.room_id = e.room_id INNER JOIN event_backward_extremities as b ON g.prev_event_id = b.event_id AND g.room_id = b.room_id WHERE b.room_id = ? AND g.is_state is ? GROUP BY b.event_id'
    txn.execute(sql, (room_id, False))
    return dict(txn.fetchall())

dataset/ETHPy150Open matrix-org/synapse/synapse/storage/event_federation.py EventFederationStore.get_oldest_events_with_depth_in_room_txn/original