def estimate_recent_invites(realms: Iterable[Realm], *, days: int) -> int:
    'An upper bound on the number of invites sent in the last `days` days'
    recent_invites = RealmCount.objects.filter(realm__in=realms, property='invites_sent::day', end_time__gte=(timezone_now() - datetime.timedelta(days=days))).aggregate(Sum('value'))['value__sum']
    if (recent_invites is None):
        return 0
    return recent_invites
An upper bound on the number of invites sent in the last `days` days
def estimate_recent_invites(realms: Iterable[Realm], *, days: int) -> int:
    
    recent_invites = RealmCount.objects.filter(realm__in=realms, property='invites_sent::day', end_time__gte=(timezone_now() - datetime.timedelta(days=days))).aggregate(Sum('value'))['value__sum']
    if (recent_invites is None):
        return 0
    return recent_invites