Skip to content

京王バスのGTFSフィードを追加 - #1601

Merged
TinyKitten merged 2 commits into
devfrom
claude/keio-bus-support-mqlc0f
Jul 12, 2026
Merged

京王バスのGTFSフィードを追加#1601
TinyKitten merged 2 commits into
devfrom
claude/keio-bus-support-mqlc0f

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 12, 2026

Copy link
Copy Markdown
Member

概要

ODPT(公共交通オープンデータセンター)が公開する京王バス(京王電鉄バス)の GTFS-JP フィードを取り込み対象に追加し、京王バスの路線・停留所を StationAPI で扱えるようにします。既存の都営バス・西武バスと同じ GTFS 統合パイプラインに乗せています。

変更の種類

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

変更内容

  • GTFS_FEEDS に京王バスフィード(keio)を追加。ODPT の files/odpt/KeioBus/AllLines.zip から取得し、西武バスと同様に ODPT_ACCESS_TOKEN が必要
  • company_cd_for_gtfs_routekeio: 接頭辞を京王バス(company_cd=254)にマッピング
  • data/1!companies.csv に京王バス(company_cd=254)を追加。lines.company_cd → companies の外部キー制約を満たすため必須
  • 実行時にダウンロードされる GTFS ディレクトリ(data/KeioBus-GTFS/、および漏れていた data/SeibuBus-GTFS/)を .gitignore に追加
  • README.md / AGENTS.md / docs/architecture.md のデータソース表記・バス統合の説明を更新
  • 単体テスト test_company_cd_for_gtfs_route / test_gtfs_feeds に京王バス分を追加

補足: コードパスは動作実績のある西武バスと同一ですが、この環境に有効な ODPT_ACCESS_TOKEN が無いため、実データのダウンロード〜駅・路線への投影までの実行時検証は未実施です。トークンを設定した環境での起動確認が別途必要です。

テスト

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

上記に加え、cargo run -p data_validator を実行し [VALID] No errors reported. を確認済み。

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

  • 新機能
    • 京王電鉄バス(Keio Bus)のGTFSデータ取り込みに対応し、既存の西武バス等とあわせて利用できるようになりました。
  • ドキュメント
    • GTFSフィード取得に必要な環境変数(ODPT_ACCESS_TOKEN)や、統合対象フィード(西武・京王)を明確化しました。
    • データ提供元・ライセンス情報の記載を更新しました(README、アーキテクチャ資料、AGENTS)。
  • Chores
    • GTFSデータ用ディレクトリをGitの追跡対象から除外しました。

ODPT 公開の京王バス (京王電鉄バス) GTFS-JP フィードを取り込み対象に追加する。

- `GTFS_FEEDS` に `keio` フィードを追加(ODPT `files/odpt/KeioBus/AllLines.zip`、
  西武バスと同じく `ODPT_ACCESS_TOKEN` が必要)
- `company_cd_for_gtfs_route` で `keio:` 接頭辞を京王バス (`company_cd=254`) に対応付け
- `data/1!companies.csv` に京王バス (company_cd=254) を追加(lines→companies の
  外部キー制約を満たすため)
- ダウンロードされる GTFS ディレクトリ (KeioBus/SeibuBus) を `.gitignore` に追加
- README / AGENTS / architecture ドキュメントとデータソース表記を更新
- `test_company_cd_for_gtfs_route` / `test_gtfs_feeds` を京王バス分だけ更新

検証: cargo fmt --all -- --check / SQLX_OFFLINE=true cargo clippy -- -D warnings /
SQLX_OFFLINE=true cargo test / cargo run -p data_validator いずれも成功。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SfBspXi8MZnEjwrAxvbBzz
@TinyKitten TinyKitten self-assigned this Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 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: c85f1f14-d887-4c15-b4f4-1ac21af3119d

📥 Commits

Reviewing files that changed from the base of the PR and between 1dbdcd6 and c8c8104.

📒 Files selected for processing (2)
  • AGENTS.md
  • stationapi/src/import.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • stationapi/src/import.rs
  • AGENTS.md

📝 Walkthrough

Walkthrough

Keio BusのGTFSフィードをODPTから取得して取り込む設定を追加し、路線IDを会社コード254へ変換する処理とテストを更新しました。関連するデータソース、アーキテクチャ、運用説明、Git管理除外設定も更新されています。

Changes

Keio Bus GTFS integration

Layer / File(s) Summary
Keio Busフィードの取り込みと会社コード変換
stationapi/src/import.rs
keioフィードをODPT取得対象に追加し、keio:路線をcompany_cd=254へ変換する処理とテスト期待値を更新しました。
関連ドキュメントとデータ管理設定
.gitignore, AGENTS.md, README.md, docs/architecture.md
Keio Busのデータソース、GTFS統合仕様、会社コード対応、取得データのGit除外設定を更新しました。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GTFS_FEEDS
  participant ODPT
  participant ImportPipeline
  GTFS_FEEDS->>ODPT: keioフィードを取得
  ODPT-->>ImportPipeline: GTFSアーカイブを返却
  ImportPipeline->>ImportPipeline: keio:路線を会社コード254へ変換
Loading

Possibly related PRs

Suggested labels: deploy-dev, feature

Poem

ぴょんとKeioのバスが来て
GTFSをかごに詰め
ODPTの道を走る
254の旗を掲げ
鉄道とうさぎ跳び 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 京王バスのGTFSフィード追加という主要変更を端的に示しており、内容と一致しています。
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/keio-bus-support-mqlc0f

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

🧹 Nitpick comments (1)
stationapi/src/import.rs (1)

3138-3142: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

フィード定義の URL・パス・認証要件もテストしてください。

現在のテストは ID の並びだけを検証するため、Keio の URL、pathrequires_consumer_key が誤っていても通過します。Keio 要素を取得し、これらの値を明示的に assert してください。

修正例
     fn test_gtfs_feeds() {
         assert_eq!(
             GTFS_FEEDS.iter().map(|feed| feed.id).collect::<Vec<_>>(),
             vec!["toei", "seibu", "keio"]
         );
+        let keio = GTFS_FEEDS.iter().find(|feed| feed.id == "keio").unwrap();
+        assert_eq!(keio.path, "data/KeioBus-GTFS");
+        assert_eq!(
+            keio.url,
+            "https://api.odpt.org/api/v4/files/odpt/KeioBus/AllLines.zip"
+        );
+        assert!(keio.requires_consumer_key);
     }
🤖 Prompt for 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.

In `@stationapi/src/import.rs` around lines 3138 - 3142, Expand the
test_gtfs_feeds test to locate the Keio feed entry from GTFS_FEEDS and
explicitly assert its URL, path, and requires_consumer_key values. Preserve the
existing feed ID ordering assertion while validating these three Keio-specific
fields.
🤖 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 `@AGENTS.md`:
- Line 57: Update the nearby TrainType description and ODPT_ACCESS_TOKEN
documentation to refer to all configured GTFS feeds, explicitly including Seibu
Bus and Keio Bus where appropriate. Align both descriptions with the all-feed
behavior documented in the GTFS bus integration section, without changing
implementation details.

---

Nitpick comments:
In `@stationapi/src/import.rs`:
- Around line 3138-3142: Expand the test_gtfs_feeds test to locate the Keio feed
entry from GTFS_FEEDS and explicitly assert its URL, path, and
requires_consumer_key values. Preserve the existing feed ID ordering assertion
while validating these three Keio-specific fields.
🪄 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: CHILL

Plan: Pro

Run ID: 7ded6e8c-32df-4440-bebf-386800ce2345

📥 Commits

Reviewing files that changed from the base of the PR and between e732749 and 1dbdcd6.

⛔ Files ignored due to path filters (1)
  • data/1!companies.csv is excluded by !**/*.csv
📒 Files selected for processing (5)
  • .gitignore
  • AGENTS.md
  • README.md
  • docs/architecture.md
  • stationapi/src/import.rs

Comment thread AGENTS.md
- `test_gtfs_feeds` で京王バスフィードの name / path / url /
  requires_consumer_key を明示的に assert し、ID の並びだけでなく
  定義値の誤りも検知できるようにする
- `AGENTS.md` の TrainType 説明を Toei Bus 限定表現から設定済み全
  GTFSフィード (Toei / Seibu / Keio) へ更新
- `AGENTS.md` の `ODPT_ACCESS_TOKEN` 説明に京王バスを追記

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SfBspXi8MZnEjwrAxvbBzz
@TinyKitten
TinyKitten merged commit 2ea8022 into dev Jul 12, 2026
13 checks passed
@TinyKitten
TinyKitten deleted the claude/keio-bus-support-mqlc0f branch July 12, 2026 07:52
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