Skip to content

走行シミュレーション用 gRPC クエリ GetTrainRoute を追加 - #1568

Merged
TinyKitten merged 9 commits into
devfrom
feature/expose-arrival-estimation-via-grpc
Jun 30, 2026
Merged

TinyKitten merged 9 commits into
devfrom
feature/expose-arrival-estimation-via-grpc

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

概要

A駅→B駅を指定列車種別(line_group_id)1本で走行する際の各駅情報を 1リクエストで返す gRPC クエリ GetTrainRoute を追加します。各駅に停車/通過フラグ・直前駅からの距離(m)・最高速度/加減速度(SI単位)を付与し、MobileApp の useSimulationMode が端末内で行っていた経路・速度プロファイル準備をサーバ側に集約します。

注意: proto submodule に EstimateArrivalTimes RPC も含まれますが、そのハンドラ実装は別 PR で行います。EstimateArrivalTimes PR を先にマージしてから本 PR をマージしてください。

変更の種類

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

変更内容

  • stationapi/proto: gRPCProto submodule を更新。GetTrainRoute RPC、TrainRouteSegment/GetTrainRouteRequest/TrainRouteResponse メッセージを追加
  • use_case/dto/simulation.rs(新規): 走行速度・加減速度の定数と resolve_speed_profile(line_type, is_bus, kind)。MobileApp の simulationMode 定数と一致。単体テスト付き
  • use_case/traits/query.rs / use_case/interactor/query.rs: QueryUseCase::get_train_route を追加。既存の get_stations_by_line_group_id と haversine_distance を再利用し、新規SQLなし
  • presentation/controller/grpc.rs: get_train_route ハンドラを追加

テスト

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

EstimateArrivalTimes ハンドラ未実装のため、proto が要求する trait メソッドが不足しビルド不可。EstimateArrivalTimes PR マージ後に通る想定。

関連Issue

Refs #1564
Supersedes #1565

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

Summary by CodeRabbit

  • 新機能
    • gRPCで列車ルート(区間)を取得できる「ルート詳細」エンドポイントを追加。
    • 区間ごとの情報(停車条件など)と、距離・路線/車両/列車種別に基づく速度条件を反映して返します。
  • 改善
    • バスは路線より優先して速度プロファイルを適用し、種別(特急など)では最大速度に上限を設定。
    • line_group_id が未指定の場合は入力エラー(必須)を返します。

TinyKitten and others added 5 commits June 29, 2026 23:59
gRPCProto submoduleを更新し、EstimateArrivalTimes RPCと
EstimatedArrivalResponse/Route/Stopメッセージを追加。
gRPCコントローラに既存のestimate_route_arrival_timesユースケースへの
結線を実装し、経路ごとにグルーピングしたレスポンスを返す。

Closes #1562

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A駅→B駅を指定列車種別(line_group_id)で走行する際の各駅情報を
1リクエストで返すGetTrainRouteを実装。各駅に停車/通過フラグ・
直前駅からの距離(m, Haversine)・最高速度/加減速度(SI単位)を
付与し、MobileAppのuseSimulationModeが端末内で行っていた
経路・速度プロファイル準備をサーバ側に集約する。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@TinyKitten TinyKitten self-assigned this Jun 29, 2026
@github-actions github-actions Bot added the feature 要望対応や課題解決 label Jun 29, 2026
@coderabbitai

coderabbitai Bot commented Jun 29, 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: CHILL

Plan: Pro

Run ID: 637734af-99dc-4cc0-b07d-a1add8cd717a

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb8ea1 and d016178.

📒 Files selected for processing (1)
  • stationapi/src/presentation/controller/grpc.rs
💤 Files with no reviewable changes (1)
  • stationapi/src/presentation/controller/grpc.rs

📝 Walkthrough

Walkthrough

get_train_route を公開契約から gRPC まで追加し、路線種別・車種に基づく速度プロファイル解決を新設しました。あわせて既存の estimate_route_arrival_times は trait と実装から外されています。

Changes

get_train_route 機能追加

Layer / File(s) Summary
QueryUseCase 契約変更と proto 更新
stationapi/proto, stationapi/src/use_case/traits/query.rs
QueryUseCase trait に get_train_route を追加し、estimate_route_arrival_times を削除。proto サブモジュールの参照コミットを更新。
SpeedProfile と resolve_speed_profile の新規実装
stationapi/src/use_case/dto.rs, stationapi/src/use_case/dto/simulation.rs
simulation DTO モジュールを新規追加。SpeedProfile 構造体と、路線種別・バスフラグ・車種種別から速度プロファイルを決定する resolve_speed_profile 関数を実装し、ユニットテストを追加。
QueryInteractor への get_train_route 実装
stationapi/src/use_case/interactor/query.rs
get_train_route を実装。line_group の駅列から対象区間を抽出し、隣接駅間の Haversine 距離と resolve_speed_profile で各区間の TrainRouteSegment を組み立てる。estimate_route_arrival_times の実装と関連 import を削除。
gRPC コントローラーへの get_train_route 追加
stationapi/src/presentation/controller/grpc.rs
MyApi に get_train_route エンドポイントを追加。line_group_id の必須バリデーション、ユースケース呼び出し、TrainRouteResponse へのマッピングを実装。テスト用 MockQueryUseCase のスタブも更新。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TrainLCD/StationAPI#1563: estimate_route_arrival_times の実装・契約を変更しており、本 PR でその削除・置換が行われているため直接関連しています。
  • TrainLCD/StationAPI#1566: grpc.rs と QueryUseCase の経路推定 RPC 周りを同系統で変更しており、変更対象が重なっています。

Poem

🐇 ぴょん、ぴょん、新しい路線をたどる
速度を選んで、区間をつなぐ
バスは先に、特急はきゅっと速く
うさぎのコードは今日も軽やか
にんじん色の未来へ、すすむよ 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 主要変更であるGetTrainRouteのgRPCクエリ追加を簡潔に表しており、内容と一致しています。
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.
✨ 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 feature/expose-arrival-estimation-via-grpc

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


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

@TinyKitten TinyKitten changed the title 走行シミュレーション用 gRPC クエリ GetTrainRoute / EstimateArrivalTimes を追加 走行シミュレーション用 gRPC クエリ GetTrainRoute を追加 Jun 29, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TinyKitten and others added 3 commits June 30, 2026 21:51
…-estimation-via-grpc

# Conflicts:
#	stationapi/src/presentation/controller/grpc.rs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-dev feature 要望対応や課題解決

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant