def points_awarded(target=None, source=None, since=None):
    """
    Determine out how many points the given target has received.
    """

    lookup_params = {}

    if target is not None:
        if isinstance(target, get_user_model()):
            lookup_params["target_user"] = target
        else:
            lookup_params.update({
                "target_content_type": ContentType.objects.get_for_model(target),
                "target_object_id": target.pk,
            })
    if source is not None:
        if isinstance(source, get_user_model()):
            lookup_params["source_user"] = source
        else:
            lookup_params.update({
                "source_content_type": ContentType.objects.get_for_model(source),
                "source_object_id": source.pk,
            })

    if since is None:
        if target is not None and source is None:
            try:
                return TargetStat.objects.get(**lookup_params).points
            except TargetStat.DoesNotExist:
                return 0
        else:
            return AwardedPointValue.points_awarded(**lookup_params)
    else:
        lookup_params["timestamp__gte"] = since
        return AwardedPointValue.points_awarded(**lookup_params)
Determine out how many points the given target has received.