mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-10 04:20:44 +02:00
refac
This commit is contained in:
@@ -9,6 +9,7 @@ from open_webui.internal.db import Base, JSONField, get_db, get_db_context
|
||||
from open_webui.models.tags import TagModel, Tag, Tags
|
||||
from open_webui.models.folders import Folders
|
||||
from open_webui.models.chat_messages import ChatMessage, ChatMessages
|
||||
from open_webui.models.automations import AutomationRun
|
||||
from open_webui.utils.misc import sanitize_data_for_db, sanitize_text_for_db
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
@@ -1478,6 +1479,9 @@ class ChatTable:
|
||||
def delete_chat_by_id(self, id: str, db: Optional[Session] = None) -> bool:
|
||||
try:
|
||||
with get_db_context(db) as db:
|
||||
db.query(AutomationRun).filter_by(chat_id=id).update(
|
||||
{AutomationRun.chat_id: None}, synchronize_session=False
|
||||
)
|
||||
db.query(ChatMessage).filter_by(chat_id=id).delete()
|
||||
db.query(Chat).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
@@ -1489,6 +1493,9 @@ class ChatTable:
|
||||
def delete_chat_by_id_and_user_id(self, id: str, user_id: str, db: Optional[Session] = None) -> bool:
|
||||
try:
|
||||
with get_db_context(db) as db:
|
||||
db.query(AutomationRun).filter_by(chat_id=id).update(
|
||||
{AutomationRun.chat_id: None}, synchronize_session=False
|
||||
)
|
||||
db.query(ChatMessage).filter_by(chat_id=id).delete()
|
||||
db.query(Chat).filter_by(id=id, user_id=user_id).delete()
|
||||
db.commit()
|
||||
@@ -1503,6 +1510,9 @@ class ChatTable:
|
||||
self.delete_shared_chats_by_user_id(user_id, db=db)
|
||||
|
||||
chat_id_subquery = db.query(Chat.id).filter_by(user_id=user_id).subquery()
|
||||
db.query(AutomationRun).filter(AutomationRun.chat_id.in_(chat_id_subquery)).update(
|
||||
{AutomationRun.chat_id: None}, synchronize_session=False
|
||||
)
|
||||
db.query(ChatMessage).filter(ChatMessage.chat_id.in_(chat_id_subquery)).delete(
|
||||
synchronize_session=False
|
||||
)
|
||||
@@ -1517,6 +1527,9 @@ class ChatTable:
|
||||
try:
|
||||
with get_db_context(db) as db:
|
||||
chat_id_subquery = db.query(Chat.id).filter_by(user_id=user_id, folder_id=folder_id).subquery()
|
||||
db.query(AutomationRun).filter(AutomationRun.chat_id.in_(chat_id_subquery)).update(
|
||||
{AutomationRun.chat_id: None}, synchronize_session=False
|
||||
)
|
||||
db.query(ChatMessage).filter(ChatMessage.chat_id.in_(chat_id_subquery)).delete(
|
||||
synchronize_session=False
|
||||
)
|
||||
|
||||
@@ -378,9 +378,10 @@
|
||||
<div class="space-y-2.5">
|
||||
<div class="flex items-center justify-between text-xs">
|
||||
<span class="text-gray-600 dark:text-gray-400">{$i18n.t('State')}</span>
|
||||
<span class="flex items-center gap-1.5 text-xs {is_active
|
||||
? 'text-emerald-700 dark:text-emerald-400'
|
||||
: 'text-gray-600 dark:text-gray-400'}"
|
||||
<span
|
||||
class="flex items-center gap-1.5 text-xs {is_active
|
||||
? 'text-emerald-700 dark:text-emerald-400'
|
||||
: 'text-gray-600 dark:text-gray-400'}"
|
||||
>
|
||||
<span
|
||||
class="inline-block size-1.5 rounded-full {is_active
|
||||
@@ -409,8 +410,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 flex flex-col min-h-0">
|
||||
<div class="text-gray-500 text-xs mb-2 shrink-0">
|
||||
<div class="flex-1 flex flex-col min-h-0 -mx-1">
|
||||
<div class="text-gray-500 text-xs mb-2 mx-1 shrink-0">
|
||||
{$i18n.t('Execution Logs')}
|
||||
</div>
|
||||
<div class="flex-1 overflow-y-auto scrollbar-hidden w-full" on:scroll={onScroll}>
|
||||
@@ -426,7 +427,7 @@
|
||||
<div class="space-y-0.5 w-full">
|
||||
{#each runs as run (run.id)}
|
||||
<button
|
||||
class="w-full text-left flex items-center gap-2.5 px-2.5 py-2 rounded-xl hover:bg-gray-100/80 dark:hover:bg-gray-850/80 transition-colors {run.chat_id
|
||||
class="w-full text-left flex items-center gap-2.5 px-2.5 py-1.5 rounded-xl hover:bg-gray-100/80 dark:hover:bg-gray-850/80 transition-colors {run.chat_id
|
||||
? 'cursor-pointer'
|
||||
: 'cursor-default'}"
|
||||
on:click={() => {
|
||||
|
||||
Reference in New Issue
Block a user