'Get all the client account_data for a user.
Args:
user_id(str): The user to get the account_data for.
Returns:
A deferred pair of a dict of global account_data and a dict
mapping from room_id string to per room account_data dicts.'

@cached()
def get_account_data_for_user(self, user_id):

    def get_account_data_for_user_txn(txn):
        rows = self._simple_select_list_txn(txn, 'account_data', {'user_id': user_id}, ['account_data_type', 'content'])
        global_account_data = {row['account_data_type']: json.loads(row['content']) for row in rows}
        rows = self._simple_select_list_txn(txn, 'room_account_data', {'user_id': user_id}, ['room_id', 'account_data_type', 'content'])
        by_room = {}
        for row in rows:
            room_data = by_room.setdefault(row['room_id'], {})
            room_data[row['account_data_type']] = json.loads(row['content'])
        return (global_account_data, by_room)
    return self.runInteraction('get_account_data_for_user', get_account_data_for_user_txn)
