From 53583f8d8341ce9d81782c4712671c4c9c2d480b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 1 Apr 2026 04:33:30 -0500 Subject: [PATCH] refac --- backend/open_webui/models/automations.py | 21 ------------------ backend/open_webui/routers/automations.py | 27 ----------------------- src/lib/apis/automations/index.ts | 27 ----------------------- 3 files changed, 75 deletions(-) diff --git a/backend/open_webui/models/automations.py b/backend/open_webui/models/automations.py index 3591fc831..05440dd6e 100644 --- a/backend/open_webui/models/automations.py +++ b/backend/open_webui/models/automations.py @@ -152,18 +152,6 @@ class AutomationTable: row = db.get(Automation, id) return AutomationModel.model_validate(row) if row else None - def get_by_user( - self, user_id: str, db: Optional[Session] = None - ) -> list[AutomationModel]: - with get_db_context(db) as db: - rows = ( - db.query(Automation) - .filter_by(user_id=user_id) - .order_by(Automation.created_at.desc()) - .all() - ) - return [AutomationModel.model_validate(r) for r in rows] - def search_automations( self, user_id: str, @@ -206,15 +194,6 @@ class AutomationTable: total=total, ) - def get_all(self, db: Optional[Session] = None) -> list[AutomationModel]: - with get_db_context(db) as db: - rows = ( - db.query(Automation) - .order_by(Automation.created_at.desc()) - .all() - ) - return [AutomationModel.model_validate(r) for r in rows] - def update_by_id( self, id: str, diff --git a/backend/open_webui/routers/automations.py b/backend/open_webui/routers/automations.py index 6375cb7e4..8f23e47e1 100644 --- a/backend/open_webui/routers/automations.py +++ b/backend/open_webui/routers/automations.py @@ -71,22 +71,6 @@ def enrich_automation( ) -############################ -# GetAutomations -############################ - - -@router.get('/', response_model=list[AutomationResponse]) -async def get_automations( - request: Request, - user=Depends(get_verified_user), - db: Session = Depends(get_session), -): - check_automations_permission(request, user) - automations = Automations.get_by_user(user.id, db=db) - return [enrich_automation(automation, db, tz=user.timezone) for automation in automations] - - ############################ # GetAutomationItems (paginated) ############################ @@ -299,15 +283,4 @@ async def get_automation_runs( return AutomationRuns.get_by_automation(id, skip=skip, limit=limit, db=db) -############################ -# Admin Endpoints -############################ - -@router.get('/admin/all', response_model=list[AutomationModel]) -async def get_all_automations( - request: Request, - user=Depends(get_admin_user), - db: Session = Depends(get_session), -): - return Automations.get_all(db=db) diff --git a/src/lib/apis/automations/index.ts b/src/lib/apis/automations/index.ts index 3d4c9cd4f..e02309890 100644 --- a/src/lib/apis/automations/index.ts +++ b/src/lib/apis/automations/index.ts @@ -49,33 +49,6 @@ export type AutomationResponse = { next_runs: number[] | null; }; -export const getAutomations = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/automations/`, { - method: 'GET', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - authorization: `Bearer ${token}` - } - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - error = err.detail; - console.error(err); - return null; - }); - - if (error) { - throw error; - } - - return res; -}; export const getAutomationItems = async ( token: string,