GetStationsByLineIdList RPC追加#1388
Merged
Merged
Conversation
複数のline_idを一括で処理するバッチRPCを追加。 既存のGetStationByIdList/GetLineByIdListと同じバッチパターンに従う。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthrough複数の行IDで駅情報を一括取得するAPI/ユースケース/リポジトリ経路が追加され、protoサブモジュール参照が更新されました。新しい非同期メソッド群が公開インターフェースと各実装に導入されています。 Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant gRPC as gRPC API
participant UseCase as Query UseCase
participant Repository as Station Repository
participant DB as Database
Client->>gRPC: get_stations_by_line_id_list(line_ids, transport_type)
gRPC->>UseCase: get_stations_by_line_id_vec(line_ids, transport_type)
UseCase->>Repository: get_by_line_id_vec(line_ids)
Repository->>DB: SELECT ... WHERE line_cd IN (...)
DB-->>Repository: station_rows
Repository-->>UseCase: Vec<Station>
UseCase->>UseCase: filter by transport_type / update attributes
UseCase-->>gRPC: Vec<Station>
gRPC->>gRPC: build MultipleStationResponse
gRPC-->>Client: MultipleStationResponse
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@stationapi/src/infrastructure/station_repository.rs`:
- Around line 614-706: get_by_line_id_vec currently orders by s.line_cd which
doesn't preserve the input order from line_ids; change the ORDER BY to use a
CASE expression like ORDER BY CASE l.line_cd WHEN $1 THEN 1 WHEN $2 THEN 2 ...
ELSE 999 END, s.e_sort, s.station_cd so the rows follow the input line_ids order
(same approach as get_by_id_vec). Build that CASE dynamically using the existing
line_ids iteration (the params / query_str construction), keep binding ids to
the query as you already do, and replace the fixed "ORDER BY s.line_cd, s.e_sort
ASC, s.station_cd ASC" with the CASE-based ordering in get_by_line_id_vec.
🧹 Nitpick comments (2)
stationapi/src/domain/repository/station_repository.rs (1)
111-118: モックのフィルタは HashSet+ソートで安定化できます
テスト用途でも順序が不定だと将来の検証で不安定になるので、line_ids を集合化し、結果を決まったキーでソートすると安全です。♻️ 参考修正案
- let result: Vec<Station> = self - .stations - .values() - .filter(|station| line_ids.contains(&(station.line_cd as u32))) - .cloned() - .collect(); - Ok(result) + let line_id_set: std::collections::HashSet<u32> = line_ids.iter().copied().collect(); + let mut result: Vec<Station> = self + .stations + .values() + .filter(|station| line_id_set.contains(&(station.line_cd as u32))) + .cloned() + .collect(); + result.sort_by_key(|s| (s.line_cd, s.station_cd)); + Ok(result)stationapi/src/use_case/interactor/query.rs (1)
195-212: 空の line_ids は早期リターンで無駄な処理を省けます
リポジトリ側でも空入力は扱えますが、属性付与まで走らないようにすると軽くなります。♻️ 参考修正案
async fn get_stations_by_line_id_vec( &self, line_ids: &[u32], transport_type: TransportTypeFilter, ) -> Result<Vec<Station>, UseCaseError> { + if line_ids.is_empty() { + return Ok(vec![]); + } let stations = self.station_repository.get_by_line_id_vec(line_ids).await?;
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
複数のline_idを一括で処理するバッチRPCを追加。
既存のGetStationByIdList/GetLineByIdListと同じバッチパターンに従う。
Summary by CodeRabbit