Skip to content

新幹線の速度プロファイルが種別上限130km/hに引き下げられる問題を修正 - #1587

Merged
TinyKitten merged 2 commits into
devfrom
claude/trainroute-nozomi-speed-nq62ou
Jul 4, 2026
Merged

新幹線の速度プロファイルが種別上限130km/hに引き下げられる問題を修正#1587
TinyKitten merged 2 commits into
devfrom
claude/trainroute-nozomi-speed-nq62ou

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 4, 2026

Copy link
Copy Markdown
Member

概要

TrainRoute の新幹線区間(例: 東海道新幹線のぞみ 新横浜→名古屋)で最高速度が大幅に過小になる問題を修正しました。のぞみ等の新幹線種別は kind=LimitedExpress で登録されているため、resolve_speed_profile が路線種別 BulletTrain の 320km/h ではなく種別上限の 130km/h を返してしまっていました。

変更の種類

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

変更内容

  • resolve_speed_profile の種別上限(LimitedExpress / HighSpeedRapid → 130km/h)を、路線種別上限との max に変更。種別上限は在来線の速達種別を底上げするための値であり、新幹線(320km/h)を引き下げないようにした
  • 新幹線 + LimitedExpress 種別で 320km/h が維持されることを確認する回帰テストを追加

テスト

  • cargo fmt --all -- --check が通ること
  • cargo clippy -- -D warnings が通ること
  • cargo test(SQLX_OFFLINE=true)が通ること

関連Issue

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01SDYiyztD7z8FmDUCEqUHBt


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • 特急・高速快速の最高速度判定を見直し、路線本来の上限と種別下限(床)の高い方が反映されるよう修正しました。
    • 新幹線では、列車種別の上限により不要に速度が引き下げられないようになりました。
  • Tests
    • 上限の期待値(引き上げ/引き下げ有無)に合わせてテストを更新しました。

のぞみ等の新幹線種別は kind=LimitedExpress で登録されているため、
resolve_speed_profile が路線種別 BulletTrain の 320km/h ではなく
種別上限の 130km/h を返してしまい、TrainRoute の新幹線区間
(例: 新横浜→名古屋)の最高速度が大幅に過小になっていた。

種別上限は在来線の速達種別を底上げするための値なので、
路線種別の上限との max を取り、路線上限より遅くならないようにする。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SDYiyztD7z8FmDUCEqUHBt
@TinyKitten TinyKitten self-assigned this Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7142a3e6-d4a6-46d3-9ae6-3fdc0b7193e6

📥 Commits

Reviewing files that changed from the base of the PR and between 255d73c and ed37563.

📒 Files selected for processing (1)
  • stationapi/src/use_case/dto/simulation.rs

📝 Walkthrough

Walkthrough

resolve_speed_profilemax_speed 判定を変更し、LimitedExpress/HighSpeedRapid では固定値ではなく路線由来の速度と下限値の最大値を採用するようにした。あわせて、BulletTrain で速度が引き下げられないことを検証するテストを更新・追加した。

Changes

速度プロファイル判定の変更

Layer / File(s) Summary
max_speed 判定ロジックとテストの変更
stationapi/src/use_case/dto/simulation.rs
LimitedExpress/HighSpeedRapidmax_speedline_max_speed と下限値の最大値に変更し、BulletTrain で路線上限を引き下げない挙動をテストで確認するよう更新した。

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

うさぎが見たよ、速度の道
特急はぐんと、でも線路はそのまま
新幹線は減速しない
テストもぴょんと追いかける 🐇🚄

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 新幹線の速度が種別上限で下がる問題の修正を具体的に示しており、変更内容と一致しています。
Description check ✅ Passed 概要・変更種類・変更内容・テストが揃っており、テンプレートの必須項目をほぼ満たしています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/trainroute-nozomi-speed-nq62ou

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@stationapi/src/use_case/dto/simulation.rs`:
- Around line 43-48: Update the naming in simulation.rs to reflect that
LIMITED_EXPRESS_KIND_MAX_SPEED is now used as a floor rather than a cap: rename
the constant and any related references in the max_speed logic and the test
named limited_express_kind_caps_speed_over_line_type so the symbols clearly
communicate “bottoming up” behavior. Keep the match in the simulation DTO
aligned with the new name and adjust the test description to match the actual
rule for TrainTypeKind::LimitedExpress and TrainTypeKind::HighSpeedRapid.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2033d44e-ee1e-4d2c-ba75-05fe01502e94

📥 Commits

Reviewing files that changed from the base of the PR and between 04b4d21 and 255d73c.

📒 Files selected for processing (1)
  • stationapi/src/use_case/dto/simulation.rs

Comment thread stationapi/src/use_case/dto/simulation.rs Outdated
@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TinyKitten
TinyKitten merged commit 73a71f3 into dev Jul 4, 2026
11 checks passed
@TinyKitten
TinyKitten deleted the claude/trainroute-nozomi-speed-nq62ou branch July 4, 2026 13:56
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.

2 participants