From bfddd98ae2d60de75751d15b5a66719c0c5db5c9 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 10 Jul 2023 23:34:38 +0800 Subject: [PATCH] fix --- app/api/endpoints/dashboard.py | 9 +++++++-- app/chain/search.py | 6 +++--- app/utils/timer.py | 2 ++ nginx.conf | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/api/endpoints/dashboard.py b/app/api/endpoints/dashboard.py index 954ededd..262a6f3c 100644 --- a/app/api/endpoints/dashboard.py +++ b/app/api/endpoints/dashboard.py @@ -82,11 +82,16 @@ def schedule(_: schemas.TokenPayload = Depends(verify_token)) -> Any: continue if not StringUtils.is_chinese(job.name): continue + next_run = TimerUtils.time_difference(job.next_run_time) + if not next_run: + status = "已停止" + else: + status = "等待" if job.pending else "运行中" schedulers.append(schemas.ScheduleInfo( id=job.id, name=job.name, - status="等待" if job.pending else "运行中", - next_run=TimerUtils.time_difference(job.next_run_time) or "已停止" + status=status, + next_run=next_run )) return schedulers diff --git a/app/chain/search.py b/app/chain/search.py index 227989f1..6f6cc295 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -45,8 +45,8 @@ class SearchChain(ChainBase): results = self.process(mediainfo=mediainfo) # 保存眲结果 self.systemconfig.set(SystemConfigKey.SearchResults, - pickle.dumps(results or [])) - return results or [] + pickle.dumps(results)) + return results def search_by_title(self, title: str) -> List[TorrentInfo]: """ @@ -84,7 +84,7 @@ class SearchChain(ChainBase): def process(self, mediainfo: MediaInfo, keyword: str = None, - no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None) -> Optional[List[Context]]: + no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None) -> List[Context]: """ 根据媒体信息搜索种子资源,精确匹配,应用过滤规则,同时根据no_exists过滤本地已存在的资源 :param mediainfo: 媒体信息 diff --git a/app/utils/timer.py b/app/utils/timer.py index 5a86898d..acea9390 100644 --- a/app/utils/timer.py +++ b/app/utils/timer.py @@ -42,6 +42,8 @@ class TimerUtils: @staticmethod def time_difference(input_datetime: datetime) -> str: + if not input_datetime: + return "" current_datetime = datetime.datetime.now(datetime.timezone.utc).astimezone() time_difference = input_datetime - current_datetime diff --git a/nginx.conf b/nginx.conf index c369b876..e13e2a33 100644 --- a/nginx.conf +++ b/nginx.conf @@ -53,6 +53,26 @@ http { proxy_pass http://backend_api; } + location ~ ^/(api/v1/system/message|api/v1/system/progress/) { + # SSE MIME类型设置 + default_type text/event-stream; + + # 禁用缓存 + add_header Cache-Control no-cache; + add_header X-Accel-Buffering no; + + # 代理设置 + proxy_pass http://backend_api; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # 超时设置 + proxy_read_timeout 3600s; + } + location /api { # 后端API proxy_pass http://backend_api;