|
@@ -38,6 +38,17 @@ import db
|
|
|
|
|
|
|
|
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8772
|
|
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8772
|
|
|
MATRIX_FILE = HERE / "reference" / "judged_matrix.json"
|
|
MATRIX_FILE = HERE / "reference" / "judged_matrix.json"
|
|
|
|
|
+_MATRIX_CACHE = None
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _matrix():
|
|
|
|
|
+ """judged_matrix.json 解析后模块级缓存(只读,进程内不变)。"""
|
|
|
|
|
+ global _MATRIX_CACHE
|
|
|
|
|
+ if _MATRIX_CACHE is None:
|
|
|
|
|
+ _MATRIX_CACHE = json.loads(MATRIX_FILE.read_text(encoding="utf-8"))
|
|
|
|
|
+ return _MATRIX_CACHE
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
LOG_DIR = HERE / "runs" / "logs"
|
|
LOG_DIR = HERE / "runs" / "logs"
|
|
|
# 工序步骤 via 字段的「无具体工具」占位符,不计入工序提及工具 TOP 榜
|
|
# 工序步骤 via 字段的「无具体工具」占位符,不计入工序提及工具 TOP 榜
|
|
|
_VIA_PLACEHOLDERS = {"-", "—", "-", "--", "/", "无", "n/a", "none"}
|
|
_VIA_PLACEHOLDERS = {"-", "—", "-", "--", "/", "无", "n/a", "none"}
|
|
@@ -422,6 +433,8 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
|
self.end_headers()
|
|
self.end_headers()
|
|
|
self.wfile.write(body)
|
|
self.wfile.write(body)
|
|
|
|
|
+ elif u.path == "/api/query_matrix":
|
|
|
|
|
+ self._json_etag(_matrix())
|
|
|
elif u.path == "/api/dashboard":
|
|
elif u.path == "/api/dashboard":
|
|
|
self._json_etag(_dashboard_cached())
|
|
self._json_etag(_dashboard_cached())
|
|
|
elif u.path == "/api/queries":
|
|
elif u.path == "/api/queries":
|