Skip to content

線路の長さと求め直した較正をtrainRouteのEstimatedだけで使い、estimateArrivalTimesとconnectedRoutesを元の計算に戻した - #1714

Merged
TinyKitten merged 1 commit into
devfrom
fix/scope-track-distance-to-estimated
Sep 30, 2026
Merged

TinyKitten merged 1 commit into
devfrom
fix/scope-track-distance-to-estimated

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

概要

#1712 の新しい計算 (駅間の距離に線路の長さを使い、その距離で求め直した速度の較正) を、trainRoute の Estimated だけで使うようにしました。estimateArrivalTimes と connectedRoutes は、#1712 の前の計算に戻します。

#1712 の目的は、MobileApp の開発用 GPX を実際の運行に近づけることでした。GPX の生成が使うのは trainRoute の Estimated だけですが、#1712 は共有の推定に変更を入れたので、アプリの ETA (estimateArrivalTimes) と経路検索 (connectedRoutes) の結果まで変わっていました。新しい計算を必要な場所に閉じ込め、ほかは元の挙動に戻します。

変更の種類

  • バグ修正
  • 新機能
  • データの修正・追加
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • 推定の較正を選べるようにした (arrival_estimation.rs)
  • Estimated だけが新しい計算を使う (query.rs)
    • trainRoute の Estimated は、lineGroupId でも legs でも、求め直した較正と線路の長さで推定します。
    • estimateArrivalTimes は、legs のあり・なしとも、元の較正と直線距離 × 迂回係数に戻しました。
    • legs の推定を非公開の estimate_legs にまとめ、estimateArrivalTimes と Estimated で較正と距離だけを切り替えます。乗換の徒歩と待ち時間の組み立て方は共通です。
  • 経路検索を元の計算に戻した (src/repository.rs)
  • 所要時間のベンチマーク (src/travel_times.rs・scripts/travel_time_report.py)
  • テスト
  • ドキュメント
    • AGENTS.md・docs/architecture.md・travel_times/README.md・scripts/README.md と各テーブルの先頭のコメントに、求め直した計算を使うのは Estimated だけであることを書きました。

本番・ステージングとの比較

このブランチを make data && make dev で起動した Worker に同じ問い合わせを送りました。Estimated 以外は本番 (#1710 の前)、Estimated は今のステージング (#1712) と比べています。

問い合わせ 比べた相手 一致
trainRoute の Legacy (lineGroupId あり、駅だけ、legs) 本番 121 / 121
estimateArrivalTimes (方向あり、方向なし、legs) 本番 121 / 121
connectedRoutes (60 組 × 並べ方 3 通り) 本番 180 / 180
trainRoute の Estimated (lineGroupId、legs) ステージング 61 / 61

問い合わせは、無作為に選んだ 60 の種別グループと駅グループの組から作りました。make travel-time-report の値 (21 件、典型からのずれの平均 4.71%) も、ステージングの値と同じです。

テスト

  • make fmt が通ること
  • make clippy が通ること(wasm32 ターゲットを含む)
  • make test が通ること

cargo fmt --all -- --check、make clippy、make test を実行し、すべて成功しました (stationapi 443 件、stationapi-worker 28 件ほか、失敗なし)。make test は、generated/ がある状態と data/*.csv だけの状態の両方で通しています。

関連Issue

Refs #1712

スクリーンショット(任意)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能
    • trainRoute の Estimated モデルで、再較正済みの速度テーブルと線路距離に基づく所要時間推定を行うようになりました。線路距離がない駅間は、直線距離と迂回係数で補います。
    • バスを含む経路では、Estimated の推定値は Legacy と同じになります。
  • ドキュメント
    • 推定モデルごとに使われる距離・速度較正の違いと、所要時間レポートの計測対象を更新しました。

…dRoutesを元の計算に戻した

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TinyKitten TinyKitten self-assigned this Sep 30, 2026
@github-actions github-actions Bot added fix 直した deploy-dev rust and removed fix 直した labels Sep 30, 2026
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: d878298e-548a-4ef0-a296-ee53bfad7e67

📥 Commits

Reviewing files that changed from the base of the PR and between 5f13885 and 0edcbb2.

📒 Files selected for processing (12)
  • AGENTS.md
  • docs/architecture.md
  • scripts/README.md
  • scripts/travel_time_report.py
  • src/repository.rs
  • src/travel_times.rs
  • stationapi/src/domain/arrival_estimation.rs
  • stationapi/src/domain/legacy_speed_table.rs
  • stationapi/src/domain/segment_speed_table.rs
  • stationapi/src/domain/speed_table.rs
  • stationapi/src/use_case/interactor/query.rs
  • travel_times/README.md

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

Estimated trainRoute の推定に再較正済み速度と線路距離を適用します。estimateArrivalTimes と connectedRoutes は従来の較正と距離処理を維持します。テスト、レポート、ドキュメントも Estimated trainRoute を対象に更新しています。

Changes

Estimated trainRoute の推定

Layer / File(s) Summary
較正方式と適用範囲
stationapi/src/domain/arrival_estimation.rs, stationapi/src/domain/*speed_table.rs, AGENTS.md, docs/architecture.md, scripts/README.md
SpeedCalibration に Original と Recalibrated を追加し、既定値を Original に設定しました。路線速度と区間速度は選択した方式に応じた較正表を使います。関連ドキュメントに各表の適用範囲を記載しています。
Estimated 経路推定の実装
stationapi/src/use_case/interactor/query.rs, src/repository.rs
Estimated trainRoute の区間推定に再較正パラメータと線路距離を適用します。通常の経路推定は既定パラメータと従来の距離処理を使います。テストは駅列、停車判定、時間の順序、および Estimated 経路同士の時刻を検証します。
Estimated 推定のテストと計測
src/travel_times.rs, scripts/travel_time_report.py, travel_times/README.md, docs/architecture.md
回帰計測とレポート用クエリを trainRoute の Estimated モデルに変更しました。レポートは segments から駅 ID と到着・出発累積時間を読み取ります。

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant QueryInteractor
  participant estimate_legs
  participant ArrivalEstimation
  participant speed_table
  participant segment_speed_table
  QueryInteractor->>estimate_legs: 区間列と Estimated モデルを渡す
  estimate_legs->>ArrivalEstimation: 再較正パラメータと線路距離を渡す
  ArrivalEstimation->>speed_table: 路線速度を参照する
  ArrivalEstimation->>segment_speed_table: 対象区間の速度上書きを参照する
  ArrivalEstimation-->>estimate_legs: 推定時間を返す
Loading

Merge Risk: ⚪ Minimal · up to 0edcb

The calibration split and updated measurements appear consistent with the intended behavior. No actionable merge-blocking issue is established; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、線路距離と再較正をtrainRouteのEstimatedだけに適用し、estimateArrivalTimesとconnectedRoutesを元の計算に戻す主変更を明確に示しています。
Description check ✅ Passed 概要、変更種類、変更内容、テスト結果、関連Issueが記載されています。必須テストの実行結果と本番・ステージングとの比較結果も具体的です。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


うさぎは線路をぴょんと渡り
新しい速度表をのぞきこむ
Estimated の時刻をたどって
到着と出発を数えたら
月まで軽やかに跳ねていく

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant