def count_usage():
    personal = collections.defaultdict(dict)
    group = collections.defaultdict(dict)
    for node in models.Node.find():
        tree = node.get_addon('osfstorage').file_tree
        if not tree:
            continue
        for record in tree.children:
            for version in record.versions:
                size = version.size or version.metadata.get('size')
                if not size:
                    continue
                size = int(size)
                personal[version.creator][version._id] = size
                for user in node.contributors:
                    group[user][version._id] = size
    return personal, group
Count personal and group file space usage.
dataset/ETHPy150Open CenterForOpenScience/osf.io/scripts/analytics/tabulate_files_usage.py/count_usage