CSVインポートとGTFSインポートを並行実行#1525
Conversation
CREATE EXTENSION と create_table.sql の実行を create_schema として import_csv から分離し、スキーマ作成後に CSV と GTFS のインポートを tokio::spawn で並行起動する。 GTFS はバックグラウンドのまま、CSV 完了時点でサーバ起動・ヘルスチェック 通過。CSV 完了後に GTFS の完了を待って integrate_gtfs_to_stations と ANALYZE を実行する。GTFS 失敗時の挙動は従来通り warn のみ。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughStartup flow refactored to separate schema initialization from import logic, enabling parallel CSV/GTFS imports. Health check now monitors database station count rather than assuming serving state. Environment configuration centralized with validation and fallback defaults. ChangesStartup initialization and parallel import refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stationapi/src/import.rs (1)
41-67: 💤 Low value
.parse()によるStringへの変換は不要
String::from_utf8_lossy()はCow<str>を返すため、.parse::<String>()を経由する必要はありません。.to_string()または.into_owned()で直接Stringに変換できます。♻️ 修正案
- let create_sql: String = String::from_utf8_lossy(&create_sql_content).parse()?; + let create_sql: String = String::from_utf8_lossy(&create_sql_content).into_owned();🤖 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 41 - 67, The create_schema function is converting the file bytes to a String via String::from_utf8_lossy(...).parse() which is unnecessary and forces a parse Result; replace the parse step by converting the Cow<str> directly to an owned String (use .into_owned() or .to_string()) for the variable create_sql (derived from create_sql_content/create_sql_path) so sqlx::raw_sql receives a String without using .parse().
🤖 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.
Nitpick comments:
In `@stationapi/src/import.rs`:
- Around line 41-67: The create_schema function is converting the file bytes to
a String via String::from_utf8_lossy(...).parse() which is unnecessary and
forces a parse Result; replace the parse step by converting the Cow<str>
directly to an owned String (use .into_owned() or .to_string()) for the variable
create_sql (derived from create_sql_content/create_sql_path) so sqlx::raw_sql
receives a String without using .parse().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cf57f538-10f7-4b96-ba09-988a6fe2d030
📒 Files selected for processing (2)
stationapi/src/import.rsstationapi/src/main.rs
概要
CSV インポートと GTFS インポートを並行実行する構造に再編し、両方の合計所要時間を短縮する。
変更の種類
変更内容
import_csvからCREATE EXTENSIONおよびcreate_table.sqlの実行をcreate_schemaとして分離main.rsでcreate_schemaを先行実行した後、GTFS インポートをtokio::spawnでバックグラウンド起動し、CSV インポートと並行実行JoinHandleを待機し、integrate_gtfs_to_stationsとANALYZEを実行warnログのみで継続テスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit