from typing import Counter


def count_totals(records, key_getter):
    """ Get the download totals for each provider registered in the database

    :param key_getter: Function used to determine the key of the object
    :type key_getter: callable
    :param records: list of history records
    :type records: tranny.models.Base[]
    :return: Dict with totals for each key corresponding to a providers name
    :rtype: dict[]
    """
    counts = Counter()
    for r in records:
        counts[key_getter(r)] += 1
    return counts