Skip to content

GetStationsByLineGroupIdList RPC追加#1389

Merged
TinyKitten merged 3 commits into
devfrom
feature/tt-batch
Feb 8, 2026
Merged

GetStationsByLineGroupIdList RPC追加#1389
TinyKitten merged 3 commits into
devfrom
feature/tt-batch

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Feb 8, 2026

Copy link
Copy Markdown
Member

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • New Features
    • 複数の路線グループIDをまとめて指定し、一度に複数の駅情報を取得できる機能を追加しました。
    • 複数ID向けのAPIエンドポイント(一覧リクエスト)を追加し、一覧取得が可能になりました。
    • 一括取得に伴う属性付与やフィルタ処理を拡張し、既存のフィルタやレスポンス形式との整合性を維持します。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

複数の line_group_id を一括で扱うベクトル化メソッド群を追加し、リポジトリ/ユースケース/gRPC コントローラ層を横断して get_by_line_group_id_vec / get_stations_by_line_group_id_vec を実装しています(プロト submodule 参照更新を含む)。

変更内容

Cohort / File(s) Summary
プロトサブモジュール更新
stationapi/proto
サブモジュール参照を更新(b050805...7eede39...)。
ドメイン層リポジトリ
stationapi/src/domain/repository/station_repository.rs
トレイトに get_by_line_group_id_vec(&[u32]) を追加。テストモックに対応実装を追加。
インフラ層リポジトリ
stationapi/src/infrastructure/station_repository.rs
get_by_line_group_id_vec の実装追加。複数ID向けSQLバインド、結果マッピング、入力順序保持(CASE-based ORDER BY)、空入力時は空ベクタ返却。
ユースケース層
stationapi/src/use_case/traits/query.rs, stationapi/src/use_case/interactor/query.rs
get_stations_by_line_group_id_vec(&[u32], transport_type) を QueryUseCase に追加/実装。取得後に update_station_vec_with_attributes で属性付与するフローを追加。テストモックを拡張。
プレゼンテーション(gRPC)
stationapi/src/presentation/controller/grpc.rs
gRPC メソッド get_stations_by_line_group_id_listGetStationsByLineGroupIdListRequest 型を追加。MockQueryUseCase に get_stations_by_line_group_id_vec を追加し、コントローラ実装でユースケースを呼び出すよう変更。

シーケンス図

sequenceDiagram
    participant Client as gRPC Client
    participant API as StationApi\n(Controller)
    participant UseCase as QueryUseCase\n(Interactor)
    participant StationRepo as StationRepository\n(Infrastructure)
    participant DB as Database

    Client->>API: get_stations_by_line_group_id_list\n(GetStationsByLineGroupIdListRequest)
    API->>UseCase: get_stations_by_line_group_id_vec(line_group_ids, transport_type)
    UseCase->>StationRepo: get_by_line_group_id_vec(line_group_ids)
    StationRepo->>DB: SQL SELECT ... WHERE line_group_cd IN (...)
    DB-->>StationRepo: rows
    StationRepo-->>UseCase: Vec<Station>
    UseCase->>UseCase: update_station_vec_with_attributes(Vec<Station>)
    UseCase-->>API: Vec<Station>
    API-->>Client: MultipleStationResponse
Loading

推定コードレビュー工数

🎯 3 (中程度) | ⏱️ ~25分

関連する可能性のあるPR

推奨レビュアー

  • 10mocy

🐰 みみを立ててコードを掘るよ、
いくつもの線を一緒に辿る旅、
ベクタで集めて属性を添え、
リポジトリは歌い API が返す、
うさぎの跳躍で機能は跳ねる!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトル「GetStationsByLineGroupIdList RPC追加」は、変更セットの主要な変更内容(複数のline_group_idで駅を取得するRPCメソッドの追加)を正確に反映している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/tt-batch

No actionable comments were generated in the recent review. 🎉


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

@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: 2

🤖 Fix all issues with AI agents
In `@stationapi/proto`:
- Line 1: CI is failing because the stationapi/proto submodule points to an
invalid commit (referenced as 6f5474…) that cannot be fetched; fix by either
updating the submodule pointer in the superproject to a valid, existing commit
and committing that change, or make the missing commit reachable from the
submodule's remote (push the commit or add a tag/branch that includes it), then
re-run git submodule update so stationapi/proto resolves successfully.

In `@stationapi/src/domain/repository/station_repository.rs`:
- Around line 226-239: get_by_line_group_id_vec currently uses unwrap_or(0) on
station.line_group_cd which makes None match when line_group_ids contains 0;
change the filter to only match when station.line_group_cd is Some and its value
(cast to u32) is contained in line_group_ids so behavior matches
get_by_line_group_id (e.g., use station.line_group_cd.map(|v| v as
u32).map_or(false, |gid| line_group_ids.contains(&gid)) or an explicit pattern
match); update the filter closure in get_by_line_group_id_vec to check for
Some(...) rather than using unwrap_or(0).

Comment thread stationapi/proto Outdated
Comment thread stationapi/src/domain/repository/station_repository.rs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@TinyKitten TinyKitten merged commit 3f36bed into dev Feb 8, 2026
10 checks passed
@TinyKitten TinyKitten deleted the feature/tt-batch branch February 8, 2026 05:31
TinyKitten added a commit that referenced this pull request Feb 8, 2026
* GetStationsByLineIdList RPC追加

複数のline_idを一括で処理するバッチRPCを追加。
既存のGetStationByIdList/GetLineByIdListと同じバッチパターンに従う。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* cargo fmt

* get_by_line_id_vecのORDER BYを入力順序保持のCASE式に変更

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Merge pull request #1389 from TrainLCD/feature/tt-batch

GetStationsByLineGroupIdList RPC追加

* get_stations_by_line_group_id_vecで列車種別を一括取得してセット (#1390)

* get_stations_by_line_group_id_vecで列車種別を一括取得してセット

N+1問題を回避しつつ、train_type_repository.get_by_line_group_id_vecで
複数line_group_idの列車種別を1クエリで取得し、top-levelとlines[].station
の両方にセットするよう修正。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* get_stations_by_line_group_id_vecのユニットテストを追加

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ネストされた駅のtrain_typeをis_some()で明示的に検証するよう修正

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* train_typeをtrain_type_mapから常に上書きしてリーク防止

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>
TinyKitten added a commit that referenced this pull request Mar 6, 2026
* master<-dev (#1337)

* GetRoutesMinimal RPCを実装 (#1334)

* Add minimal route retrieval functionality and related proto types

* Refactor code formatting for improved readability in grpc.rs and query.rs

* Add line symbols to LineMinimal in get_lines_by_station_group_id

* Update subproject commit reference in stationapi/proto

* Add get_lines_by_id_list method and update QueryUseCase trait

* Refactor import order for improved readability in grpc.rs

* Use entry method for inserting line_minimal in all_lines to avoid overwriting

* Refactor route_row_tree_map creation into a separate build_route_tree_map method for improved readability

* Enhance line symbol handling in QueryInteractor: populate line_symbols for all lines and update line_minimal entries conditionally

* Refactor line symbol handling in QueryInteractor: update all_lines conditionally based on line_symbols presence

* Add AGENTS.md for automation agent and contributor workflow guidelines

* Update AGENTS.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* 石橋阪大前駅ローカライズ修正 (#1336)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* master<-dev (#1374)

* SQLの致命的なバグをいくつか修正 (#1371)

* ひらがな混じりで駅検索ができないバグを修正

* get_train_types_by_station_idが動かないバグを修正

* GetStationsByLineGroupIdの修正

* ユニットテスト拡充

* cargo fmt

* バス路線はline_typeをOtherLineTypeに強制 (#1372)

* direction_idがNULLのトリップに存在するバス停も正しく取り込むよう修正 (#1373)

* direction_idがNULLのトリップに存在するバス停も正しく取り込むよう修正

GTFSの仕様ではdirection_idはオプショナルであり、NULLの場合でも
バス停は有効な停留所として扱うべきである。

これまではvariant_only_with_neighbors CTEで「direction_id IS NOT NULL」
のトリップにのみ存在するバス停をフィルタリングしていたため、
早81の原宿駅前や渋谷駅東口などのバス停がレスポンスから除外されていた。

* バリアントバス停の位置推定でメイントリップに存在する隣接バス停を優先

variant_only_with_neighborsでバス停の隣接情報を選択する際に、
隣接バス停(prev_stop_id/next_stop_id)がメイントリップに存在する
レコードを優先するよう修正。

これにより、原宿駅前などのバス停がより正確な位置に挿入される。

---------

Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>

* 西鉄データ更新 (#1375)

* 春日原駅を特急停車駅に指定

* 聖マリア病院前の駅名修正

* master<-dev (#1391)

* GetStationsByLineIdList RPC追加

複数のline_idを一括で処理するバッチRPCを追加。
既存のGetStationByIdList/GetLineByIdListと同じバッチパターンに従う。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* cargo fmt

* get_by_line_id_vecのORDER BYを入力順序保持のCASE式に変更

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Merge pull request #1389 from TrainLCD/feature/tt-batch

GetStationsByLineGroupIdList RPC追加

* get_stations_by_line_group_id_vecで列車種別を一括取得してセット (#1390)

* get_stations_by_line_group_id_vecで列車種別を一括取得してセット

N+1問題を回避しつつ、train_type_repository.get_by_line_group_id_vecで
複数line_group_idの列車種別を1クエリで取得し、top-levelとlines[].station
の両方にセットするよう修正。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* get_stations_by_line_group_id_vecのユニットテストを追加

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ネストされた駅のtrain_typeをis_some()で明示的に検証するよう修正

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* train_typeをtrain_type_mapから常に上書きしてリーク防止

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: Tsubasa SEKIGUCHI <oss@tinykitten.me>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant