def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int:
    log_statsd_event('bankruptcy')
    all_push_message_ids = UserMessage.objects.filter(user_profile=user_profile).extra(where=[UserMessage.where_active_push_notification()]).values_list('message_id', flat=True)[0:10000]
    do_clear_mobile_push_notifications_for_ids([user_profile.id], all_push_message_ids)
    msgs = UserMessage.objects.filter(user_profile=user_profile).extra(where=[UserMessage.where_unread()])
    count = msgs.update(flags=F('flags').bitor(UserMessage.flags.read))
    event = dict(type='update_message_flags', operation='add', flag='read', messages=[], all=True)
    event_time = timezone_now()
    send_event(user_profile.realm, event, [user_profile.id])
    do_increment_logging_stat(user_profile, COUNT_STATS['messages_read::hour'], None, event_time, increment=count)
    do_increment_logging_stat(user_profile, COUNT_STATS['messages_read_interactions::hour'], None, event_time, increment=min(1, count))
    return count
def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int:
    log_statsd_event('bankruptcy')
    all_push_message_ids = UserMessage.objects.filter(user_profile=user_profile).extra(where=[UserMessage.where_active_push_notification()]).values_list('message_id', flat=True)[0:10000]
    do_clear_mobile_push_notifications_for_ids([user_profile.id], all_push_message_ids)
    msgs = UserMessage.objects.filter(user_profile=user_profile).extra(where=[UserMessage.where_unread()])
    count = msgs.update(flags=F('flags').bitor(UserMessage.flags.read))
    event = dict(type='update_message_flags', operation='add', flag='read', messages=[], all=True)
    event_time = timezone_now()
    send_event(user_profile.realm, event, [user_profile.id])
    do_increment_logging_stat(user_profile, COUNT_STATS['messages_read::hour'], None, event_time, increment=count)
    do_increment_logging_stat(user_profile, COUNT_STATS['messages_read_interactions::hour'], None, event_time, increment=min(1, count))
    return count