def METHOD_NAME(all_users: bool = False) -> Response:
    verify_logged_in()
    u = get_current_user_object()
    q = (
        Block.query.filter_by(type_id=BlockType.ScheduledFunction.value)
        .join(BlockAccess)
        .filter(BlockAccess.type == AccessType.owner.value)
        .join(PeriodicTask)
        .with_entities(PeriodicTask)
        .options(
            joinedload(PeriodicTask.block)
            .joinedload(Block.accesses)
            .joinedload(BlockAccess.usergroup)
        )
    )
    if all_users:
        verify_admin()
    if not all_users:
        q = q.filter(BlockAccess.block_id.in_(get_owned_objects_query(u).subquery()))
    scheduled_fns: list[PeriodicTask] = q.all()
    docentries = DocEntry.query.filter(
        DocEntry.id.in_([t.task_id.doc_id for t in scheduled_fns])
    ).all()
    d_map = {d.id: d for d in docentries}
    def gen() -> Generator[ScheduledFunctionItem, None, None]:
        for t in scheduled_fns:
            yield ScheduledFunctionItem(
                block_id=t.block_id,
                name=t.task_id.task_name,
                expires=t.expires,
                last_run_at=t.last_run_at,
                total_run_count=t.total_run_count,
                interval=Interval(every=t.interval.every, period=t.interval.period),
                owners=t.block.owners,
                doc_path=d_map[t.task_id.doc_id].path,
                enabled=t.enabled,
            )
    return json_response(list(gen()), date_conversion=True)