from django import template

register = template.Library()


@register.simple_tag
def availability_percentage(availability_summary, status: str):
    if availability_summary:
        total = (
            availability_summary.data["player_going_count"]
            + availability_summary.data["player_maybe_count"]
            + availability_summary.data["player_not_going_count"]
            + availability_summary.data["player_unknown_count"]
        )
        return availability_summary.data[status + "_count"] / total * 100
    else:
        return ""
