Skip to content

バス路線でGetStationsByLineIdが0件になる問題を種別なし駅一覧へのフォールバックで修正 - #1622

Merged
TinyKitten merged 2 commits into
devfrom
feature/fix-bus-line-stations-empty
Aug 6, 2026
Merged

バス路線でGetStationsByLineIdが0件になる問題を種別なし駅一覧へのフォールバックで修正#1622
TinyKitten merged 2 commits into
devfrom
feature/fix-bus-line-stations-empty

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 6, 2026

Copy link
Copy Markdown
Member

概要

バス路線で GetStationsByLineId が常に0件を返し、アプリでバス停一覧が全く表示されなくなっていた問題を修正します。

#1614「列車種別なしの経路分岐を削除」で、種別を持たない駅向けのフォールバック(get_by_line_id_without_train_types)が削除され、get_by_line_id_with_train_type に一本化されました。しかし統合後のクエリの target_line_group CTE は t.kind IN (0,1) OR t.priority > 0 で種別グループを選択するため、BusRoutekind=7priority=0)しか種別を持たないバス路線ではグループが一切マッチせず、常に空の結果を返していました。#1612 の各停種別の起動時補完は transport_type = 0(鉄道)限定のため、バス停は補完対象外です。

変更の種類

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

変更内容

  • get_by_line_id_with_train_type で種別グループベースのクエリが0件だった場合に、種別なしの駅一覧クエリへフォールバックするように変更(列車種別なしの経路分岐を削除 #1614 で削除された get_by_line_id_without_train_types を復元)
  • 鉄道路線は従来どおり1クエリで返り、バス路線のみ2クエリ目に落ちるため、列車種別なしの経路分岐を削除 #1614 以前と同等のクエリコスト
  • 統合テストを追加(鉄道路線の種別グループ駅列 / バス路線のフォールバック / station_id 未指定 / direction_id による並び順反転の4ケース)
  • AGENTS.md の Stations 節に GetStationsByLineId のフォールバック挙動を追記
  • 復元したフォールバック関数とテストフィクスチャに doc コメントを追加(CodeRabbit の docstring カバレッジ警告対応)

テスト

  • cargo fmt --all -- --check が通ること
  • cargo clippy -- -D warnings が通ること(SQLX_OFFLINE=true
  • cargo testSQLX_OFFLINE=true)が通ること(427 + 41 件パス)

追加の統合テストはローカルの PostgreSQL 16 に対して TEST_DATABASE_URL=... cargo test --lib --package stationapi --features integration-tests test_get_by_line_id_with_train_type_falls_back_for_bus_lines で実行し、パスを確認済みです。なお line_repository / train_type_repository の既存統合テスト27件はベースコミット(5c82996)でも同様に失敗するローカル環境依存の問題で、本変更とは無関係です(CI では integration-tests feature が無効のため実行されません)。

関連Issue

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01LM9j6JJciEV1jmhLTt7Hod

@github-actions github-actions Bot added the feature 要望対応や課題解決 label Aug 6, 2026
@TinyKitten TinyKitten self-assigned this Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

get_by_line_id_with_train_type は、検索結果が空の場合に種別なしの駅一覧へフォールバックします。鉄道路線の既存結果を維持し、バス路線では全停留所を返します。方向指定時は駅順を反転します。

Changes

駅一覧取得フォールバック

Layer / File(s) Summary
種別なし取得へのフォールバック
stationapi/src/infrastructure/station_repository.rs
種別付き検索が空の場合に、路線、駅、別名情報を種別なしで取得します。方向指定時は駅順を反転します。
フォールバック動作の統合検証
stationapi/src/infrastructure/station_repository.rs, AGENTS.md
隔離スキーマと鉄道・バス用データセットを追加しました。種別付き結果、全停留所、方向指定時の逆順を検証します。動作説明を更新しました。

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

Sequence Diagram(s)

sequenceDiagram
  participant GetStationsByLineId
  participant get_by_line_id_with_train_type
  participant get_by_line_id_without_train_types
  GetStationsByLineId->>get_by_line_id_with_train_type: 列車種別付き駅一覧を要求
  get_by_line_id_with_train_type->>get_by_line_id_without_train_types: 結果が空の場合にフォールバック
  get_by_line_id_without_train_types-->>GetStationsByLineId: 種別なし駅一覧を返却
Loading

Possibly related PRs

Suggested labels: fix

Poem

うさぎが駅を数えます
種別がなくても道は続きます
バス停も空にはなりません
逆向き列車は順番を変えます
ぴょん、と一覧が返ります

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
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.
Title check ✅ Passed タイトルは、バス路線で駅一覧が0件になる問題を種別なし駅一覧へのフォールバックで修正する主変更を明確に示しています。
Description check ✅ Passed 概要、変更種類、変更内容、テスト結果、関連Issue、任意項目を含み、変更の背景と検証内容を十分に説明しています。
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix-bus-line-stations-empty

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

@TinyKitten
TinyKitten merged commit 008c507 into dev Aug 6, 2026
11 checks passed
@TinyKitten
TinyKitten deleted the feature/fix-bus-line-stations-empty branch August 6, 2026 03:39
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.

2 participants