From 5e01feb755920dcc291df169aa713ffdc3e76b55 Mon Sep 17 00:00:00 2001 From: alfaadriel Date: Wed, 6 May 2026 06:40:35 +0000 Subject: [PATCH] =?UTF-8?q?fix(connector=5Fservice):=20add=20TIMEZONE=20se?= =?UTF-8?q?tting=20and=20correct=20interval=20log=E2=80=A6=20(#14446)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? ### Type of change - [v] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: wiratama --- api/db/services/connector_service.py | 7 ++++--- common/settings.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/db/services/connector_service.py b/api/db/services/connector_service.py index 85d495d9d6..40f0b7b5ca 100644 --- a/api/db/services/connector_service.py +++ b/api/db/services/connector_service.py @@ -29,6 +29,7 @@ from api.db.services.document_service import DocMetadataService from api.utils.common import hash128 from common.misc_utils import get_uuid from common.constants import TaskStatus +from common.settings import TIMEZONE from common.time_utils import current_timestamp, timestamp_to_date class ConnectorService(CommonService): @@ -179,14 +180,14 @@ class SyncLogsService(CommonService): else: database_type = os.getenv("DB_TYPE", "mysql") if "postgres" in database_type.lower(): - interval_expr = SQL("make_interval(mins => t2.refresh_freq)") + expr = SQL(f"NOW() AT TIME ZONE '{TIMEZONE}' - make_interval(mins => t2.refresh_freq)") else: - interval_expr = SQL("INTERVAL `t2`.`refresh_freq` MINUTE") + expr = SQL("NOW() - INTERVAL `t2`.`refresh_freq` MINUTE") query = query.where( Connector.input_type == InputType.POLL, Connector.status == TaskStatus.SCHEDULE, cls.model.status == TaskStatus.SCHEDULE, - cls.model.update_date < (fn.NOW() - interval_expr) + cls.model.update_date < expr ) query = query.distinct().order_by(cls.model.update_time.desc()) diff --git a/common/settings.py b/common/settings.py index 2b67dc34d7..067ae77657 100644 --- a/common/settings.py +++ b/common/settings.py @@ -43,6 +43,8 @@ import memory.utils.es_conn as memory_es_conn import memory.utils.infinity_conn as memory_infinity_conn import memory.utils.ob_conn as memory_ob_conn +TIMEZONE = os.getenv("TZ", "Asia/Shanghai") + LLM = None LLM_FACTORY = None LLM_BASE_URL = None