Skip to content

sidsのディープリンクで開いた経路でもstations(ids)が返す線路の長さを乗車距離に使うようにした - #7114

Merged
TinyKitten merged 1 commit into
feature/ride-reviewfrom
feature/ride-review-stations-by-ids-track-distance
Sep 29, 2026
Merged

TinyKitten merged 1 commit into
feature/ride-reviewfrom
feature/ride-review-stations-by-ids-track-distance

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

概要

sids のディープリンクで開いた経路でも、振り返り機能の乗車距離を線路の長さで計算するようにしました(#7103)。

StationAPI の stations(ids) が、指定した ID の順で隣り合う駅のあいだの線路の長さを返すようになりました(TrainLCD/StationAPI#1708)。アプリは sids の経路の駅をこの問い合わせで取ります。これまでは値が返らなかったので、その乗車は直線距離で記録していました(#7110 のリグレッションリスクに書いた件です)。

このPRは epic 用の親ブランチ feature/ride-review に向けています。このブランチは #7112 で canary にマージしたあと origin から消えていました。そのため、消える前の先端(28513c3e2)で作り直しています。

変更の種類

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

変更内容

  • src/lib/graphql/queries.ts: GET_STATIONS_BY_IDS で trackDistanceFromPrevious も取るようにしました。
  • src/lib/trackDistances.ts: gqlRequest の応答から線路の長さを拾う問い合わせに、stations を足しました。
    • 目的地エージェントも GET_STATIONS_BY_IDS を使います。こちらは経路の順とは限らない並びで ID を渡します。
    • 並びで隣り合っていても、線路のデータ上で隣り合わない組には null が返ります。今の実装は、null が返った組の値を表から消します。
    • それでも、lineStations などで覚えた値は消えません。StationAPI は、どの問い合わせでも同じ組の表(connections.bin)から値を引きます。stations(ids) で null になる組は、lineStations でも値が入りません。
  • src/lib/trackDistances.test.ts: stations の応答を ID の並びのまま拾うケースを足しました。
  • docs/ride-log.md: 線路の長さを返す問い合わせに stations(ids) を書き足しました。

src/@types/graphql.d.ts の GetStationsByIdsQuery には、この項目を足していません。#7110 でも GetLineStationsQuery などには足していないので、それに合わせました。

リグレッションリスク

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

npm test は 311 スイート、3,465 件がすべて通りました。実機では確かめていません。

関連Issue

Closes #7103

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

UI 変更なし: 問い合わせと距離の表の変更だけで、画面の表示は変わりません。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 不具合修正
    • ディープリンクで開いた経路でも、指定順の駅情報を取得し、隣り合う駅間の距離を反映するようになりました。
    • 駅が線路上で隣接していない場合は距離を取得せず、既存の距離情報を保持します。

@TinyKitten TinyKitten self-assigned this Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: a3bde32b-2dca-4e9b-a301-aecc3fb02763

📥 Commits

Reviewing files that changed from the base of the PR and between 28513c3 and 92439bc.

📒 Files selected for processing (4)
  • docs/ride-log.md
  • src/lib/graphql/queries.ts
  • src/lib/trackDistances.test.ts
  • src/lib/trackDistances.ts

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

GET_STATIONS_BY_IDS が trackDistanceFromPrevious を取得するようになりました。距離記録処理に stations を追加し、指定 ID 順の駅間距離を記録するテストとドキュメントを更新しました。

Changes

駅 ID による線路距離の記録

Layer / File(s) Summary
駅 ID 問い合わせの距離フィールド
src/lib/graphql/queries.ts
GET_STATIONS_BY_IDS に trackDistanceFromPrevious を追加しました。GET_LINE_STATIONS と GET_LINE_GROUP_STATIONS のコメントも更新しました。
駅 ID 応答からの距離記録
src/lib/trackDistances.ts, src/lib/trackDistances.test.ts, docs/ride-log.md
距離記録処理が stations を対象にしました。指定 ID 順の隣接駅間距離を確認するテストと、取得元および駅順の説明を追加しました。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to 92439

Confirm StationAPI #1705 and #1708 are deployed before production release; otherwise the new deep-link distance path may fail against the deployed API.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、sidsのディープリンクで開いた経路にstations(ids)の線路長を乗車距離へ適用する主な変更を明確に示しています。
Description check ✅ Passed 概要、変更の種類、変更内容、リグレッションリスク、テスト、関連Issue、スクリーンショットの各項目を記載しています。StationAPIの本番デプロイ前提、テスト結果、実機テスト未実施も明記されています。
Linked Issues check ✅ Passed 直接リンクされた #7103 の要件を満たします。src/lib/graphql/queries.ts の GET_STATIONS_BY_IDS は trackDistanceFromPrevious を取得します。src/lib/trackDistances.ts は stations(ids) の指定順で駅の組を記録します。`src/utils/rideDistance.…
Out of Scope Changes check ✅ Passed 変更対象は #7103 の乗車距離計算に必要な stations(ids) の距離取得、記録処理、テスト、ドキュメントです。lineStations と lineGroupStations のコメント更新も同じ距離取得仕様を説明する補助変更です。無関係な機能の変更は確認できません。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

うさぎは駅の列を見て
距離の数字をぴょんと読む
指定の順に並ぶ駅
線路の長さも記録して
今日の道のり、ぴたりとね

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

@github-actions github-actions Bot added the react label Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant