← Back to Pull requests

feat(notice): 通知页支持各网站站内搜索 #82

Open
unknown opened this pull request with 195 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 22, 2026 13:17 UTC
Author

变更说明

通知页现有的搜索框只在已经抓到的那一两页里筛,半年前的通知永远搜不到。这个 PR 加上站内搜索,直接查各来源站点自己的全文索引。

  • 新增 notification/site_search.py:

  • - 学院 / 部门站大多是博达 CMS,首页有 search.jsp(部分站叫 ssjgy.jsp、sou.jsp)检索表单。只认带 lucenenewssearchkey 字段的表单,避免把登录框之类误当成搜索入口;入口按站点 origin 缓存,首页打不开时不缓存结论。
    - 关键词 Base64 后放进 newskeycode2 发 GET,取前两页,结果去重后按日期倒序。没有完整日期的条目不收(猜年份会把旧通知显示成今年)。
    - 找不到检索入口、或检索结果全都缺日期的站,退回「抓列表前两页 + 本地按标题筛」。
    - 需要动态验证的站沿用现有 pass_challenge_for_website。
    - 多个来源并发搜索;单个来源失败只记进 errors,不影响其他来源。
  • 新增 app/threads/SiteSearchThread.py,复用 ProcessThread / ProcessWidget,支持取消。

  • NoticeInterface:

  • - 命令栏增加「站内搜索」;在搜索框按回车或点搜索图标也会触发。输入文字时仍是原来的本地实时筛选。
    - 结果显示在单独区域,不写入本地通知缓存。已抓到过的通知复用本地对象,保留已读状态;其余点击后直接用浏览器打开。
    - 有「返回已获取的通知」按钮,清空搜索框也会自动返回。部分来源失败时给出汇总提示(最多列 3 个)。

    验证

  • 每个 bug 修复都新增或更新了可复现旧问题的回归测试。(本 PR 是新功能,不涉及 bug 修复)

  • 与已知 Issue 相关的程序错误已有明确的回归测试,并出现在 Actions 日志中。(无对应 Issue)

  • 已运行相关本地测试,并在下方列出无法运行的测试或环境。

  • 合并前 PR Tests / CI Gate 已通过。

  • 平台相关行为已由现有矩阵覆盖,或已在下方解释额外验证范围。
  • 测试证据

    新增 test/notification/test_site_search.py(TEST_DOMAIN = "notification-crawler"),用假 session 返回固定 HTML,不访问真实学校网站:

  • 检索入口识别、关键词 Base64 编码、按日期倒序、丢弃缺日期的条目

  • 同一站点的检索入口只查找一次(缓存生效)

  • 单个来源失败不影响其他来源的结果

  • 关键词为空时直接返回空结果
  • uv run --frozen python -m unittest test.notification.test_site_search test.app.test_notice_search_ui
    OK
    uv run --frozen python -m test.ci.check_test_contract
    OK: 28 product test modules are covered by 5 domains.
    

    没有覆盖:对真实学校站点的联网检索(CI 不访问外网),以及 UI 交互的自动化测试。本地环境:Windows 11,Python 3.12。

    🤖 Generated with Claude Code

    Diff: 195 lines (+146 / -49) across 2 files Reviewer: JimmyWang0417 Review duration: 30606m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 195 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.316
    Real PR Conversation Timeline
    1 comments
    "Review active on #82"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36% (MEDIUM) · Higher = larger blast radius
    36%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.2% · Safe to merge
    19.2%