Skip to content

バス停名はカタカナに変換して挿入#1355

Merged
TinyKitten merged 1 commit into
devfrom
fix/bus-katakana
Jan 2, 2026
Merged

バス停名はカタカナに変換して挿入#1355
TinyKitten merged 1 commit into
devfrom
fix/bus-katakana

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jan 2, 2026

Copy link
Copy Markdown
Member

駅名検索とかもDBにはカタカナで駅名が入っている前提なので、「とげぬき地蔵前」バス停が「とげぬき」等で部分一致しなくなっていた

Summary by CodeRabbit

リリースノート

  • New Features
    • バス停・駅名データのひらがなからカタカナへの自動変換機能を追加しました
    • GTFS統合時のバスデータ正規化処理を強化し、データの一貫性が向上しました
    • バス路線のID生成ロジックを最適化しました

✏️ Tip: You can customize this high-level summary in your review settings.

@TinyKitten TinyKitten self-assigned this Jan 2, 2026
@coderabbitai

coderabbitai Bot commented Jan 2, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

ウォークスルー

ひらがなからカタカナへの変換ヘルパーを追加し、バスGTFS統合でストップ名の正規化を実施します。また、バスデータの決定的なID生成ユーティリティ(generate_bus_line_cd、generate_bus_station_cd、generate_bus_station_g_cd)を導入し、駅関連データの挿入フローを拡張します。

変更内容

コホート / ファイル(s) 変更概要
ひらがナ・カタカナ正規化とID生成ユーティリティ
stationapi/src/import.rs
ひらがなをカタカナに変換するヘルパー関数を追加。バスGTFSの停留所名正規化を実装。bus_line_cd、bus_station_cd、bus_station_g_cdの決定的ID生成ユーティリティを導入。駅と関連する相互参照の挿入フローに正規化とID生成を統合。

推定コード審査工数

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

🐰 ひらがなをカタカナに変え
確定的なIDで統一し
バスのデータよ美しく並べ
駅の情報が更に輝く
インポート機能、すっきり洗練 ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、バス停名をカタカナに変換して挿入するという主要な変更を明確かつ簡潔に要約しており、変更内容と完全に関連している。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

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: 0

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

1160-1173: ひらがな→カタカナ変換のロジックは正しいです。

基本的なひらがな範囲(U+3041〜U+3096)とオフセット(0x60)は正確です。踊り字(ゝ→ヽ、ゞ→ヾ)は変換対象外ですが、バス停名にはほぼ使われないため問題ないでしょう。

コーディングガイドラインに従い、この関数のユニットテスト追加を検討してください(cargo test --lib --package stationapiで実行可能)。

🔎 ユニットテストの提案
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_hiragana_to_katakana() {
        assert_eq!(hiragana_to_katakana("とげぬき"), "トゲヌキ");
        assert_eq!(hiragana_to_katakana("あいうえお"), "アイウエオ");
        // 漢字はそのまま
        assert_eq!(hiragana_to_katakana("とげぬき地蔵前"), "トゲヌキ地蔵前");
        // カタカナはそのまま
        assert_eq!(hiragana_to_katakana("カタカナ"), "カタカナ");
        // 混合
        assert_eq!(hiragana_to_katakana("ひらがなカタカナ漢字"), "ヒラガナカタカナ漢字");
    }
}
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6562e0 and 19ca591.

📒 Files selected for processing (1)
  • stationapi/src/import.rs
🧰 Additional context used
📓 Path-based instructions (2)
stationapi/src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Run cargo test --lib --package stationapi or make test-unit for unit tests focusing on entities and repository mocks without database

Files:

  • stationapi/src/import.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Before committing, run cargo fmt on all Rust code
Before committing, run cargo clippy --all-targets --all-features and resolve new Clippy warnings unless covered by existing #![allow] attributes

Files:

  • stationapi/src/import.rs
🧠 Learnings (1)
📚 Learning: 2025-11-25T10:50:36.694Z
Learnt from: CR
Repo: TrainLCD/StationAPI PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T10:50:36.694Z
Learning: Applies to stationapi/src/use_case/interactor/query.rs : When modifying `QueryInteractor`, ensure enrichment steps (companies, train types, line symbols) still behave as expected and verify helper methods such as `update_station_vec_with_attributes` and `build_route_tree_map`

Applied to files:

  • stationapi/src/import.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Suite
🔇 Additional comments (1)
stationapi/src/import.rs (1)

1739-1744: 変換ロジックの適用は適切ですが、フォールバック時の動作を確認してください。

stop_name_kNoneの場合、stop.stop_nameがそのまま使用されます。stop.stop_nameにひらがなが含まれている場合、変換されずに格納される可能性があります。

フォールバック値も変換すべきか検討してください:

🔎 フォールバック時も変換する場合の修正案
             .bind(
                 stop.stop_name_k
                     .as_ref()
                     .map(|k| hiragana_to_katakana(k))
-                    .unwrap_or_else(|| stop.stop_name.clone()),
+                    .unwrap_or_else(|| hiragana_to_katakana(&stop.stop_name)),
             )

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