From 4f36fd27437ecde9173bd2d28c3654d8cd01aee9 Mon Sep 17 00:00:00 2001 From: Hsukqi Lee Date: Mon, 23 Nov 2026 00:32:07 +0800 Subject: [PATCH] feat: expose persisted corpus coverage and collection outcomes --- README.md | 3 + cmd/fastnews/abstracts_test.go | 34 +++++++ cmd/fastnews/jobs.go | 10 +- internal/catalog/coverage.go | 142 +++++++++++++++++++++++++++++ internal/httpapi/server.go | 10 +- internal/httpapi/server_test.go | 16 +++- internal/jobs/news.go | 2 +- internal/jobs/status.go | 89 ++++++++++++++++++ web/src/App.tsx | 2 + web/src/navigation.tsx | 7 ++ web/src/pages/Coverage.tsx | 156 ++++++++++++++++++++++++++++++++ web/src/types.ts | 19 ++++ web/tests/workspace.spec.ts | 34 +++++++ 13 files changed, 515 insertions(+), 9 deletions(-) create mode 100644 internal/catalog/coverage.go create mode 100644 internal/jobs/status.go create mode 100644 web/src/pages/Coverage.tsx diff --git a/README.md b/README.md index 9c7156f..a80e28a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Go 可直接提供构建后的 SPA,也可由 nginx / 静态服务器提供 `we | --- | --- | --- | | 总览 | `/` | 最新快讯、统计、研究入口、报告与下载、作者列表 | | 顶会报告 | `/top-conf/` | 会议/年份/类别筛选、向量搜索、分页、related work、报告打开与下载 | +| 数据覆盖 | `/coverage/` | 论文数、原始摘要和有效/过期总结计数、最近落盘与任务成功时间、任务失败类别 | | 领域导读 | `/field-briefing/` | 印象补全方向、向量召回、分类综述、综述/SoK、论文推荐 | | 总结汇报 | `/summary-brief/` | 全景或主题简报、发现、统计表与条形图、问答、局限与讨论 | | 安全资讯 | `/secnews/` | 资讯日历、Top 10、BleepingComputer、The Hacker News、SecurityWeek、价值分、详情折叠 | @@ -120,6 +121,8 @@ HTML 报告由 Go 模板生成。PDF 使用 Chromium,通过 `FASTNEWS_CHROME` NeurIPS 原始摘要补全读取官方论文详情页,按 PDF 路径中的论文 ID 和卷号核对身份,不用出版日期推断会议年份。每篇成功结果追加到 `top-conf/data/abstracts/_.jsonl` 并同步落盘;后续运行只请求缺少摘要的文章,失败保留此前进度。默认每次补全 12 篇,`--limit 0` 或 `--all` 处理全部缺失文章。摘要来源与正文合并后提供给分类器;已有总结若对应旧材料则不会作为当前总结进入目录/报告,重新执行 `summarize-conf` 只更新材料发生变化的记录。未补全语料的既有断点保持原行为;这里的摘要补全不调用 LLM。 +`GET /api/coverage` 根据当前本地档案统计覆盖率,不把已注册会议当作已采集语料。会议 CLI 的采集、摘要补全和总结任务会在 `top-conf/data/job_status/` 保存开始/结束、最近成功与安全的错误类别;不保存原始错误或认证 URL。开始后未留下结束记录时,页面明确说明未记录结束,不据此断言进程仍在运行。历史任务没有状态文件时显示未记录。覆盖率刷新读取已落盘的断点,统计与报告遵守同一公开/登录访问边界。 + ## 验证 ```bash diff --git a/cmd/fastnews/abstracts_test.go b/cmd/fastnews/abstracts_test.go index f184dea..7d9c92c 100644 --- a/cmd/fastnews/abstracts_test.go +++ b/cmd/fastnews/abstracts_test.go @@ -2,6 +2,7 @@ package main import ( "context" + "encoding/json" "fmt" "io" "net/http" @@ -14,6 +15,8 @@ import ( "github.com/FastR-D/FastNews/internal/catalog" "github.com/FastR-D/FastNews/internal/config" + "github.com/FastR-D/FastNews/internal/httpapi" + "github.com/FastR-D/FastNews/internal/store" ) func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { @@ -59,6 +62,33 @@ func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { })) defer model.Close() c := config.Config{Root: t.TempDir(), LLMKey: "fixture", LLMURL: model.URL} + db, err := store.Open(filepath.Join(c.Root, "accounts")) + if err != nil { + t.Fatal(err) + } + defer db.Close() + app, err := httpapi.New(c, db) + if err != nil { + t.Fatal(err) + } + assertCoverage := func(abstracts, summaries, stale int, state string) { + t.Helper() + recorder := httptest.NewRecorder() + app.Handler().ServeHTTP(recorder, httptest.NewRequest("GET", "/api/coverage", nil)) + var result struct { + Conferences []catalog.ConferenceCoverage `json:"conferences"` + } + if err := json.Unmarshal(recorder.Body.Bytes(), &result); err != nil || recorder.Code != 200 || len(result.Conferences) != 1 { + t.Fatal("coverage response", recorder.Code, recorder.Body.String(), err) + } + row := result.Conferences[0] + if row.Papers != 2 || row.Abstracts != abstracts || row.Summaries != summaries || row.StaleSummaries != stale || row.Job == nil || row.Job.State != state || row.Job.LastSuccessAt == nil { + t.Fatal("coverage did not follow persisted evidence", row) + } + if state == "failed" && (row.Job.ErrorKind != "source_http" || row.Job.HTTPStatus != 503) { + t.Fatal("failure reason was lost", row.Job) + } + } args := []string{"--conference", "neurips", "--year", "2025"} ctx := context.Background() for _, command := range []string{"fetch-conf", "summarize-conf"} { @@ -69,6 +99,7 @@ func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { if models.Load() != 2 { t.Fatal(models.Load()) } + assertCoverage(0, 2, 0, "completed") if err := job(ctx, c, "enrich-abstracts", append(append([]string{}, args...), "--limit", "1")); err != nil { t.Fatal(err) } @@ -79,6 +110,7 @@ func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { if err := job(ctx, c, "enrich-abstracts", enrichArgs); err == nil { t.Fatal("interrupted enrichment succeeded") } + assertCoverage(1, 1, 1, "failed") file := filepath.Join(c.Root, "top-conf/data/abstracts/neurips_2025.jsonl") checkpoints, err := catalog.Rows(file) if err != nil || len(checkpoints) != 1 { @@ -93,6 +125,7 @@ func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { if first.Load() != 1 || second.Load() != 2 { t.Fatal("completed papers were fetched again", first.Load(), second.Load()) } + assertCoverage(2, 0, 2, "completed") checkpoints, err = catalog.Rows(file) if err != nil || len(checkpoints) != 2 { t.Fatal("resume duplicated or lost abstracts", checkpoints, err) @@ -118,6 +151,7 @@ func TestNeuripsAbstractsResumeAndRefreshSourceBoundSummaries(t *testing.T) { if models.Load() != 4 { t.Fatal("source update did not refresh exactly the changed summaries", models.Load()) } + assertCoverage(2, 2, 0, "completed") cat.Invalidate() papers, err = cat.Papers() if err != nil || len(papers) != 2 { diff --git a/cmd/fastnews/jobs.go b/cmd/fastnews/jobs.go index c4f5cfb..e9d7cb5 100644 --- a/cmd/fastnews/jobs.go +++ b/cmd/fastnews/jobs.go @@ -55,15 +55,15 @@ func job(ctx context.Context, c config.Config, command string, args []string) er case "weekly-report": return p.Weekly(*days, *pdf) case "fetch-conf": - return p.FetchConference(ctx, *conf, *year, *rawURL) + return p.RunConferenceJob(ctx, command, *conf, *year, *limit, *rawURL) case "enrich-abstracts": count := *limit if *all { count = 0 } - return p.EnrichConferenceAbstracts(ctx, *conf, *year, count) + return p.RunConferenceJob(ctx, command, *conf, *year, count, "") case "summarize-conf": - return p.SummarizeConference(ctx, *conf, *year) + return p.RunConferenceJob(ctx, command, *conf, *year, *limit, "") case "conference-report": return p.ConferenceReport(*conf, *year, *pdf) case "update-range": @@ -73,10 +73,10 @@ func job(ctx context.Context, c config.Config, command string, args []string) er for y := *since; y <= *until; y++ { for _, conference := range []string{"usenix", "ieee-sp", "ndss", "ccs"} { fmt.Fprintln(os.Stderr, conference, strconv.Itoa(y)) - if e := p.FetchConference(ctx, conference, y, ""); e != nil { + if e := p.RunConferenceJob(ctx, "fetch-conf", conference, y, *limit, ""); e != nil { return e } - if e := p.SummarizeConference(ctx, conference, y); e != nil { + if e := p.RunConferenceJob(ctx, "summarize-conf", conference, y, *limit, ""); e != nil { return e } p.Catalog.Invalidate() diff --git a/internal/catalog/coverage.go b/internal/catalog/coverage.go new file mode 100644 index 0000000..618f35e --- /dev/null +++ b/internal/catalog/coverage.go @@ -0,0 +1,142 @@ +package catalog + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "time" +) + +type ConferenceJobStatus struct { + Stage string `json:"stage"` + State string `json:"state"` + StartedAt time.Time `json:"startedAt"` + EndedAt *time.Time `json:"endedAt,omitempty"` + LastSuccessAt *time.Time `json:"lastSuccessAt,omitempty"` + ErrorKind string `json:"errorKind,omitempty"` + HTTPStatus int `json:"httpStatus,omitempty"` +} + +type ConferenceCoverage struct { + Conference string `json:"conference"` + Name string `json:"name"` + Year int `json:"year"` + Papers int `json:"papers"` + Abstracts int `json:"abstracts"` + Summaries int `json:"summaries"` + StaleSummaries int `json:"staleSummaries"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + Job *ConferenceJobStatus `json:"job,omitempty"` +} + +func (c *Catalog) ConferenceJob(conf string, year int) (*ConferenceJobStatus, error) { + body, err := os.ReadFile(filepath.Join(c.Root, "top-conf/data/job_status", fmt.Sprintf("%s_%d.json", conf, year))) + if os.IsNotExist(err) { + return nil, nil + } + if err != nil { + return nil, err + } + var result ConferenceJobStatus + if err := json.Unmarshal(body, &result); err != nil { + return nil, err + } + return &result, nil +} + +func (c *Catalog) Coverage() ([]ConferenceCoverage, error) { + keys := map[string]bool{} + for _, pattern := range []string{"top-conf/data/conferences/*.jsonl", "top-conf/data/job_status/*.json"} { + files, err := filepath.Glob(filepath.Join(c.Root, pattern)) + if err != nil { + return nil, err + } + for _, file := range files { + keys[strings.TrimSuffix(filepath.Base(file), filepath.Ext(file))] = true + } + } + out := []ConferenceCoverage{} + for key := range keys { + at := strings.LastIndex(key, "_") + if at < 0 { + continue + } + conf := key[:at] + metadata, ok := Conferences[conf] + if !ok { + continue + } + year, err := strconv.Atoi(key[at+1:]) + if err != nil || year < 2000 || year > 2100 { + continue + } + rows, err := c.ConferenceRows(conf, year) + if err != nil { + return nil, err + } + papers := map[string]map[string]any{} + for _, row := range rows { + if id := First(Str(row, "_id"), Str(row, "link")); id != "" { + papers[id] = row + } + } + entry := ConferenceCoverage{Conference: conf, Name: metadata.Name, Year: year, Papers: len(papers)} + for _, row := range papers { + if strings.TrimSpace(Str(row, "description")) != "" { + entry.Abstracts++ + } + } + summaries, err := Rows(filepath.Join(c.Root, "top-conf/data/summary", key+"_summary.jsonl")) + if err != nil { + return nil, err + } + latest := map[string]map[string]any{} + for _, row := range summaries { + if paper, ok := row["paper"].(map[string]any); ok { + latest[First(Str(paper, "_id"), Str(paper, "link"))] = row + } + } + for id, summary := range latest { + paper := papers[id] + if paper == nil { + continue + } + if ConferenceSourceHash(paper) != Str(summary, "source_hash") { + entry.StaleSummaries++ + continue + } + if Str(summary, "category") != "" && Str(object(summary, "paper"), "summary_zh") != "" { + entry.Summaries++ + } + } + for _, path := range []string{"conferences/" + key + ".jsonl", "abstracts/" + key + ".jsonl", "summary/" + key + "_summary.jsonl"} { + info, err := os.Stat(filepath.Join(c.Root, "top-conf/data", path)) + if os.IsNotExist(err) { + continue + } + if err != nil { + return nil, err + } + modified := info.ModTime().UTC() + if entry.UpdatedAt == nil || modified.After(*entry.UpdatedAt) { + entry.UpdatedAt = &modified + } + } + entry.Job, err = c.ConferenceJob(conf, year) + if err != nil { + return nil, err + } + out = append(out, entry) + } + sort.Slice(out, func(i, j int) bool { + if out[i].Year != out[j].Year { + return out[i].Year > out[j].Year + } + return out[i].Conference < out[j].Conference + }) + return out, nil +} diff --git a/internal/httpapi/server.go b/internal/httpapi/server.go index d7ee40f..6022500 100644 --- a/internal/httpapi/server.go +++ b/internal/httpapi/server.go @@ -182,7 +182,7 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request) { e = s.auth(w, r, p) case strings.HasPrefix(p, "/api/content/"): e = s.content(w, r, p) - case p == "/api/catalog" || p == "/api/papers" || p == "/api/news" || p == "/api/reports" || p == "/api/trend": + case p == "/api/catalog" || p == "/api/papers" || p == "/api/news" || p == "/api/reports" || p == "/api/trend" || p == "/api/coverage": if e = s.viewer(r); e == nil { e = s.catalogHTTP(w, r, p) } @@ -242,6 +242,12 @@ func (s *Server) catalogHTTP(w http.ResponseWriter, r *http.Request, p string) e return store.Fail(405, "Method not allowed") } switch p { + case "/api/coverage": + coverage, err := s.Catalog.Coverage() + if err != nil { + return err + } + reply(w, r, 200, map[string]any{"conferences": coverage}) case "/api/trend": query := r.URL.Query() scope := catalog.First(query.Get("scope"), "ai") @@ -458,7 +464,7 @@ func (s *Server) static(w http.ResponseWriter, r *http.Request, p string) error } else { switch strings.TrimSuffix(p, "/") { - case "", "/index.html", "/top-conf", "/top-conf/index.html", "/field-briefing", "/field-briefing/index.html", "/summary-brief", "/summary-brief/index.html", "/inbox", "/inbox/index.html", "/impression", "/impression/index.html", "/secnews", "/secnews/index.html", "/arxiv", "/arxiv/index.html", "/trend", "/trend/index.html", "/authors", "/login", "/auth/login", "/auth/account": + case "", "/index.html", "/top-conf", "/top-conf/index.html", "/coverage", "/coverage/index.html", "/field-briefing", "/field-briefing/index.html", "/summary-brief", "/summary-brief/index.html", "/inbox", "/inbox/index.html", "/impression", "/impression/index.html", "/secnews", "/secnews/index.html", "/arxiv", "/arxiv/index.html", "/trend", "/trend/index.html", "/authors", "/login", "/auth/login", "/auth/account": rel = "index.html" default: return store.Fail(404, "Not found") diff --git a/internal/httpapi/server_test.go b/internal/httpapi/server_test.go index fbe563c..b1311f7 100644 --- a/internal/httpapi/server_test.go +++ b/internal/httpapi/server_test.go @@ -182,7 +182,7 @@ func TestLocalContentIsolationCSRFAndInbox(t *testing.T) { } func TestCatalogOldRoutesAndPrivateFiles(t *testing.T) { h := fixture(t) - for _, p := range []string{"/", "/index.html", "/top-conf/index.html", "/field-briefing/index.html", "/summary-brief/index.html", "/inbox/index.html", "/impression/index.html", "/secnews/index.html", "/arxiv/", "/arxiv/index.html", "/trend/", "/trend/index.html", "/login", "/top-conf/data/report/USENIX_2026_Report.html?download=1"} { + for _, p := range []string{"/", "/index.html", "/top-conf/index.html", "/coverage/", "/coverage/index.html", "/field-briefing/index.html", "/summary-brief/index.html", "/inbox/index.html", "/impression/index.html", "/secnews/index.html", "/arxiv/", "/arxiv/index.html", "/trend/", "/trend/index.html", "/login", "/top-conf/data/report/USENIX_2026_Report.html?download=1"} { resp, e := http.Get(h.http.URL + p) if e != nil { t.Fatal(e) @@ -358,6 +358,20 @@ func TestNewsScopeSelectsLatestPopulatedArchiveDate(t *testing.T) { } } +func TestCoverageFollowsReportVisibility(t *testing.T) { + h := fixture(t) + h.app.Config.RequireLogin = true + status, _, _ := h.request(t, "GET", "/api/coverage", nil, "", false) + if status != 401 { + t.Fatal("private coverage exposed", status) + } + h.login(t, "coverage@example.com") + status, result, _ := h.request(t, "GET", "/api/coverage", nil, "", true) + if status != 200 || len(result["conferences"].([]any)) != 1 { + t.Fatal("authenticated coverage unavailable", status, result) + } +} + func TestReleaseSymlinkAndReportAssets(t *testing.T) { h := fixture(t) link := filepath.Join(t.TempDir(), "current") diff --git a/internal/jobs/news.go b/internal/jobs/news.go index 1727983..d8d1c17 100644 --- a/internal/jobs/news.go +++ b/internal/jobs/news.go @@ -60,7 +60,7 @@ func get(ctx context.Context, raw string) ([]byte, error) { } defer resp.Body.Close() if resp.StatusCode != 200 { - return nil, fmt.Errorf("source returned HTTP %d", resp.StatusCode) + return nil, &sourceHTTPError{Status: resp.StatusCode} } b, e := io.ReadAll(io.LimitReader(resp.Body, (16<<20)+1)) if len(b) > 16<<20 { diff --git a/internal/jobs/status.go b/internal/jobs/status.go new file mode 100644 index 0000000..5fc196f --- /dev/null +++ b/internal/jobs/status.go @@ -0,0 +1,89 @@ +package jobs + +import ( + "context" + "errors" + "fmt" + "net/url" + "os" + "path/filepath" + "time" + + "github.com/FastR-D/FastNews/internal/catalog" + "github.com/FastR-D/FastNews/internal/store" +) + +type sourceHTTPError struct{ Status int } + +func (e *sourceHTTPError) Error() string { return fmt.Sprintf("source returned HTTP %d", e.Status) } + +// RunConferenceJob owns operator-visible CLI status; it never saves raw URLs/errors. +func (p *Pipeline) RunConferenceJob(ctx context.Context, stage, conf string, year, limit int, override string) (result error) { + metadata, err := conferenceInfo(conf, year) + if err != nil { + return err + } + switch stage { + case "fetch-conf": + if _, err := ConferenceURLs(conf, year); err != nil { + return err + } + case "enrich-abstracts": + if metadata.Provider != "neurips-proceedings" || limit < 0 { + return fmt.Errorf("unsupported abstract source or limit") + } + case "summarize-conf": + default: + return fmt.Errorf("unknown conference job") + } + previous, err := p.Catalog.ConferenceJob(conf, year) + if err != nil { + return err + } + status := catalog.ConferenceJobStatus{Stage: stage, State: "started", StartedAt: time.Now().UTC()} + if previous != nil { + status.LastSuccessAt = previous.LastSuccessAt + } + file := filepath.Join(p.Config.Root, "top-conf/data/job_status", fmt.Sprintf("%s_%d.json", conf, year)) + if err := writeJSON(file, status); err != nil { + return err + } + defer func() { + ended := time.Now().UTC() + status.EndedAt = &ended + status.State = "completed" + if result == nil { + status.LastSuccessAt = &ended + } else { + status.State = "failed" + status.ErrorKind = "processing" + var network *url.Error + var source *sourceHTTPError + var storage *os.PathError + var model *store.Error + switch { + case errors.As(result, &source): + status.ErrorKind = "source_http" + status.HTTPStatus = source.Status + case errors.As(result, &network): + status.ErrorKind = "network" + case errors.As(result, &storage): + status.ErrorKind = "storage" + case errors.As(result, &model): + status.ErrorKind = "model" + status.HTTPStatus = model.Status + } + } + result = errors.Join(result, writeJSON(file, status)) + }() + result = errors.New("conference job did not return") + switch stage { + case "fetch-conf": + result = p.FetchConference(ctx, conf, year, override) + case "enrich-abstracts": + result = p.EnrichConferenceAbstracts(ctx, conf, year, limit) + default: + result = p.SummarizeConference(ctx, conf, year) + } + return result +} diff --git a/web/src/App.tsx b/web/src/App.tsx index 414b6a4..53335fa 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -24,6 +24,7 @@ import { navigation, currentPage } from './navigation' import { theme } from './theme' const Home = lazy(() => import('./pages/Home')) const Papers = lazy(() => import('./pages/Papers')) +const Coverage = lazy(() => import('./pages/Coverage')) const News = lazy(() => import('./pages/News')) const Arxiv = lazy(() => import('./pages/Arxiv')) const Trend = lazy(() => import('./pages/Trend')) @@ -270,6 +271,7 @@ function Workspace() { } /> } /> } /> + } /> } diff --git a/web/src/navigation.tsx b/web/src/navigation.tsx index 63b5dd3..9db2a37 100644 --- a/web/src/navigation.tsx +++ b/web/src/navigation.tsx @@ -25,6 +25,13 @@ export const navigation = [ group: '发现与研究', description: '顶会论文总结', }, + { + to: '/coverage/', + label: '数据覆盖', + icon: ChartNoAxesCombined, + group: '发现与研究', + description: '论文与摘要采集覆盖', + }, { to: '/secnews/', label: '安全资讯', diff --git a/web/src/pages/Coverage.tsx b/web/src/pages/Coverage.tsx new file mode 100644 index 0000000..3dd0f9d --- /dev/null +++ b/web/src/pages/Coverage.tsx @@ -0,0 +1,156 @@ +import { useEffect, useState } from 'react' +import { Badge, Button, EmptyState, Select, Toolbar } from '@fastrd/ui-react' +import { useSearchParams } from 'react-router-dom' +import { api, message } from '../api' +import { useApp } from '../context' +import type { ConferenceCoverage } from '../types' +import { Busy, ErrorMessage, Metrics, PageHeading, Panel } from '../components/Common' + +const stages: Record = { + 'fetch-conf': '论文采集', + 'enrich-abstracts': '原始摘要补全', + 'summarize-conf': '分类与总结', +} +const states: Record = { + started: '已开始,未记录结束', + completed: '已完成', + failed: '失败', +} +const errors: Record = { + network: '网络请求失败', + source_http: '来源 HTTP 响应失败', + storage: '本地语料读写失败', + model: '模型服务失败', + processing: '来源校验或处理失败', +} +function date(value?: string) { + return value ? new Date(value).toLocaleString('zh-CN') : '未记录' +} + +export default function Coverage() { + const { catalog } = useApp() + const [params, setParams] = useSearchParams() + const conference = params.get('conference') || '' + const [rows, setRows] = useState([]) + const [busy, setBusy] = useState(false), + [error, setError] = useState('') + async function load() { + setBusy(true) + setError('') + try { + const result = await api<{ conferences: ConferenceCoverage[] }>('api/coverage') + setRows(result.conferences) + } catch (error) { + setError(message(error)) + } finally { + setBusy(false) + } + } + useEffect(() => { + load() + }, []) + const selected = rows.filter((row) => !conference || row.conference === conference) + const sum = (key: 'papers' | 'abstracts' | 'summaries' | 'staleSummaries') => + selected.reduce((total, row) => total + row[key], 0) + return ( + <> + + 刷新覆盖率 + + } + /> + + + + + + {busy ? ( + + ) : !selected.length ? ( + + ) : ( + selected.map((row) => ( + {row.papers} 篇论文} + > +
+
+ + +
+ {row.staleSummaries > 0 && ( + 待更新总结:{row.staleSummaries} 篇,重新生成后才计入有效总结。 + )} +
+ 最近数据更新:{date(row.updatedAt)} + 最近任务成功:{date(row.job?.lastSuccessAt)} + {row.job ? ( + <> + + 最近任务:{stages[row.job.stage] || row.job.stage} ·{' '} + {states[row.job.state] || row.job.state} + + {row.job.state === 'failed' && ( + + {errors[row.job.errorKind || ''] || '执行失败'} + {row.job.httpStatus ? `(HTTP ${row.job.httpStatus})` : ''} + ;此前已保存进度仍保留。 + + )} + + ) : ( + 尚未记录任务状态 + )} +
+
+
+ )) + )} + + ) +} diff --git a/web/src/types.ts b/web/src/types.ts index 39d2ced..09b48dc 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -83,6 +83,25 @@ export interface NewsArticle { importance?: number score?: number } +export interface ConferenceCoverage { + conference: string + name: string + year: number + papers: number + abstracts: number + summaries: number + staleSummaries: number + updatedAt?: string + job?: { + stage: string + state: string + startedAt: string + endedAt?: string + lastSuccessAt?: string + errorKind?: string + httpStatus?: number + } +} export interface Count { label: string count: number diff --git a/web/tests/workspace.spec.ts b/web/tests/workspace.spec.ts index 4a31afa..2bab672 100644 --- a/web/tests/workspace.spec.ts +++ b/web/tests/workspace.spec.ts @@ -1,5 +1,39 @@ import { test, expect, type Page } from '@playwright/test' import type { NewsArticle } from '../src/types' +test('coverage navigation and filters show actual local evidence counts', async ({ + page, + baseURL, +}, info) => { + const response = await page.request.get(route(baseURL, 'api/coverage')) + expect(response.ok()).toBeTruthy() + const { conferences } = await response.json() + expect(conferences.length).toBeGreaterThan(0) + await visit(page, baseURL, '') + if (info.project.name === 'mobile') await page.getByRole('button', { name: '打开导航' }).click() + await page.getByRole('link', { name: '数据覆盖', exact: true }).click() + await expect(page.getByRole('heading', { name: '数据覆盖', level: 1 })).toBeVisible() + await expect(page.getByTestId('coverage-row')).toHaveCount(conferences.length) + const first = conferences[0] + await expect( + page.getByRole('progressbar', { name: `${first.name} ${first.year} 原始摘要`, exact: true }), + ).toHaveAttribute('value', String(first.abstracts)) + await expect( + page.getByRole('progressbar', { name: `${first.name} ${first.year} 有效总结`, exact: true }), + ).toHaveAttribute('value', String(first.summaries)) + await page.getByLabel('覆盖会议', { exact: true }).selectOption(first.conference) + await expect(page.getByTestId('coverage-row')).toHaveCount( + conferences.filter((row: { conference: string }) => row.conference === first.conference).length, + ) + await page.reload() + await expect(page.getByLabel('覆盖会议', { exact: true })).toHaveValue(first.conference) + await page.getByRole('button', { name: '刷新覆盖率', exact: true }).click() + await expect( + page.getByRole('progressbar', { name: `${first.name} ${first.year} 原始摘要`, exact: true }), + ).toHaveAttribute('max', String(Math.max(first.papers, 1))) + expect( + await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1), + ).toBeTruthy() +}) const route = (baseURL: string | undefined, p: string) => new URL(p.replace(/^\//, ''), baseURL!.replace(/\/?$/, '/')).href test('conference panorama uses the full selected corpus instead of a saved personal topic', async ({