Reaction 看板
输入配置中的 web.auth_token 以继续。
diff --git a/reaction_board/web/queries.py b/reaction_board/web/queries.py index 4bdd5f6..382bc87 100644 --- a/reaction_board/web/queries.py +++ b/reaction_board/web/queries.py @@ -523,14 +523,13 @@ class DashboardQueries: q: str | None = None, page: int = 1, page_size: int = 20, - export: bool = False, ) -> dict[str, Any]: if sort not in VIDEO_SORTS: raise ValueError(f"不支持的排序: {sort}") if growth_days < 1 or growth_days > 365: raise ValueError("growth_days 必须在 1~365 之间") page = max(1, int(page)) - page_size = max(1, min(int(page_size), 200 if not export else 10_000)) + page_size = max(1, min(int(page_size), 200)) def run(conn: sqlite3.Connection) -> dict[str, Any]: latest = self._latest_date(conn) or self._today() @@ -607,9 +606,8 @@ class DashboardQueries: growth_available = any( item.get("growth", {}).get("available") for item in items ) - if not export: - start = (page - 1) * page_size - items = items[start:start + page_size] + start = (page - 1) * page_size + items = items[start:start + page_size] available = True reason = None if sort in {"growth", "growth_rate"} and not growth_available: @@ -732,12 +730,11 @@ class DashboardQueries: min_videos: int = 1, page: int = 1, page_size: int = 20, - export: bool = False, ) -> dict[str, Any]: if sort not in UP_SORTS: raise ValueError(f"不支持的 UP 排序: {sort}") page = max(1, int(page)) - page_size = max(1, min(int(page_size), 200 if not export else 10_000)) + page_size = max(1, min(int(page_size), 200)) min_videos = max(1, int(min_videos)) def run(conn: sqlite3.Connection) -> dict[str, Any]: @@ -813,9 +810,8 @@ class DashboardQueries: key = sort_map[sort] items.sort(key=lambda item: (key(item), item["up_mid"]), reverse=True) total = len(items) - if not export: - start = (page - 1) * page_size - items = items[start:start + page_size] + start = (page - 1) * page_size + items = items[start:start + page_size] return { "sort": sort, "within_days": within_days, @@ -1115,8 +1111,3 @@ class DashboardQueries: "telegram_enabled": bool(cfg.telegram.enabled), } return self.db.read(run) - - def export_videos(self, **filters) -> dict[str, Any]: - filters.pop("page", None) - filters.pop("page_size", None) - return self.list_videos(**filters, export=True) diff --git a/reaction_board/web/server.py b/reaction_board/web/server.py index ad07fd3..b200f86 100644 --- a/reaction_board/web/server.py +++ b/reaction_board/web/server.py @@ -7,16 +7,12 @@ from __future__ import annotations -import csv import hashlib import hmac -import io import json import mimetypes -import os import time from dataclasses import dataclass -from datetime import date from http import HTTPStatus from http.cookies import SimpleCookie from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer @@ -27,7 +23,6 @@ from urllib.parse import parse_qs, unquote, urlsplit from ..analytics import is_loopback from ..config import ConfigStore from ..database import Database -from ..timeutil import shanghai_date from .queries import DashboardQueries STATIC_ROOT = Path(__file__).resolve().parent / "static" @@ -105,7 +100,7 @@ class DashboardHandler(BaseHTTPRequestHandler): self._method_not_allowed() def _method_not_allowed(self) -> None: - self._send_error(HTTPStatus.METHOD_NOT_ALLOWED, "method_not_allowed", "Web 看板只读") + self._send_error(HTTPStatus.METHOD_NOT_ALLOWED, "method_not_allowed", "不支持该操作") # ------------------------------------------------------------ dispatch @@ -140,7 +135,7 @@ class DashboardHandler(BaseHTTPRequestHandler): self._send_error( HTTPStatus.METHOD_NOT_ALLOWED, "method_not_allowed", - "Web 看板只读", + "不支持该操作", ) return self._api(path, query, method) @@ -220,15 +215,15 @@ class DashboardHandler(BaseHTTPRequestHandler):
输入配置中的 web.auth_token 以继续。