def METHOD_NAME(email, type):
    app.logger.info(f"Apply schedule for {type} type(s)")
    if type == "all":
        query = Proposal.query
    elif type:
        query = Proposal.query.filter(Proposal.type == type)
    else:
        raise Exception("Set a type")
    proposals = (
        query.filter(
            (Proposal.potential_venue != None)  # noqa: E711
            | (Proposal.potential_time != None)  # noqa: E711
        )
        .filter(Proposal.scheduled_duration.isnot(None))
        .filter(Proposal.state.in_(["accepted", "finished"]))
        .all()
    )
    app.logger.info(f"Got {len(proposals)} proposals")
    for proposal in proposals:
        user = proposal.user
        previously_unscheduled = True
        if proposal.scheduled_venue or proposal.scheduled_time:
            previously_unscheduled = False
        if proposal.potential_venue:
            proposal.scheduled_venue = proposal.potential_venue
            proposal.potential_venue = None
        if proposal.potential_time:
            proposal.scheduled_time = proposal.potential_time
            proposal.potential_time = None
        if previously_unscheduled:
            app.logger.info(
                'Scheduling proposal "%s" by %s', proposal.title, user.email
            )
            if email:
                send_email_for_proposal(
                    proposal,
                    reason="scheduled",
                    from_address=from_email("SPEAKERS_EMAIL"),
                )
        else:
            app.logger.info('Moving proposal "%s" by %s', proposal.title, user.email)
            if email:
                send_email_for_proposal(
                    proposal, reason="moved", from_address=from_email("SPEAKERS_EMAIL")
                )
        db.session.commit()