From be3e5f3f8bf79bbc54e347d9d55bfcbb1add8647 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 19 Nov 2025 19:41:25 +0800 Subject: [PATCH] refactor: update message history deletion logic to remove newer records based on offset --- astrbot/core/db/__init__.py | 2 +- astrbot/core/db/sqlite.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/astrbot/core/db/__init__.py b/astrbot/core/db/__init__.py index 48ccb6801..2af0428d0 100644 --- a/astrbot/core/db/__init__.py +++ b/astrbot/core/db/__init__.py @@ -184,7 +184,7 @@ class BaseDatabase(abc.ABC): user_id: str, offset_sec: int = 86400, ) -> None: - """Delete platform message history records older than the specified offset.""" + """Delete platform message history records newer than the specified offset.""" ... @abc.abstractmethod diff --git a/astrbot/core/db/sqlite.py b/astrbot/core/db/sqlite.py index 202c9d892..140fb2a26 100644 --- a/astrbot/core/db/sqlite.py +++ b/astrbot/core/db/sqlite.py @@ -414,7 +414,7 @@ class SQLiteDatabase(BaseDatabase): user_id, offset_sec=86400, ): - """Delete platform message history records older than the specified offset.""" + """Delete platform message history records newer than the specified offset.""" async with self.get_db() as session: session: AsyncSession async with session.begin(): @@ -424,7 +424,7 @@ class SQLiteDatabase(BaseDatabase): delete(PlatformMessageHistory).where( col(PlatformMessageHistory.platform_id) == platform_id, col(PlatformMessageHistory.user_id) == user_id, - col(PlatformMessageHistory.created_at) < cutoff_time, + col(PlatformMessageHistory.created_at) >= cutoff_time, ), )