def calculate_associated_data(queryset, query_target):
    """Calculate associated data and attach to objects in queryset"""
    if query_target == 'run':
        for run in queryset:
            env_groups = run.plan.env_group.values_list('name', flat=True)
            if env_groups:
                run.associated_data = {'env_group': env_groups[0]}
            else:
                run.associated_data = {'env_group': None}
