import itertools


def _extract_group_summary_data(dataseries, name=None):
    """
    Given a list of dataseries, determine the earliest
    start date, latest end date, and create a string
    of their various data types.

    :param list dataseries: dataseries
    :param name: display name for the group if desired
    :type name: str or None
    :return: overall metadata for a bunch of dataseries
    :rtype: dict

    """
    start_dates = [series['start_date'] for series in dataseries]
    end_dates = [series['end_date'] for series in dataseries]
    data_types = set(list(itertools.chain.from_iterable([series['data_types'] for series in dataseries])))
    return {
        'name': name,
        'start_date': min(start_dates),
        'end_date': max(end_dates),
        'data_types': ', '.join(sorted(data_types)),
        'parameters': dataseries
    }