Skip to content

fix: rollback#88

Open
Desert-sabaku wants to merge 4 commits into
devfrom
fix-dev-branch
Open

fix: rollback#88
Desert-sabaku wants to merge 4 commits into
devfrom
fix-dev-branch

Conversation

@Desert-sabaku
Copy link
Copy Markdown
Collaborator

@Desert-sabaku Desert-sabaku commented Oct 11, 2025

Summary by CodeRabbit

  • 新機能

    • フッターにフォーム型の検索バーを追加
    • 地図の店舗情報で電話番号表示をサポート(DBにtel列追加、API提供)
    • 公開JSON経由で店舗一覧を取得する新しいエンドポイントを追加
  • スタイル

    • 検索バー用スタイル追加と既存配色の微調整
  • ドキュメント

    • データ取り込み手順を bin/rails import:stores から rails db:seed に更新、更新手順注記を追加
  • リファクタ

    • 地図表示の店舗取得/マーカー更新フローを改善(安定性・検証強化)
  • 雑務

    • シード配置の運用整理(.gitignore更新)および従来のインポートタスク削除、シード読み込み方式をJSONファイルベースに変更、テスト/フィクスチャ追加

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 11, 2025

Walkthrough

/stores エンドポイントと StoresController を追加し、フロントは /stores から検証付きで店舗一覧を取得してマーカー表示。種データは db/seeds/stores/**/*.json を読んで rails db:seed で投入。stores.tel カラムと関連マイグレーションを追加。検索UIとフッターの検索フォームを導入。

Changes

Cohort / File(s) 変更概要
Git 応答除外
\.gitignore
db/seeds/stores/* を ignore に追加し .keep を除外解除
ドキュメント
README.md
udon インポート手順を udon_list.json→db/seeds/stores/**/* + rails db:seed に更新、更新手順メモ追加
スタイル/検索UI
app/assets/stylesheets/main.scss
既存スタイルの整形(単行化)と検索バー用スタイル新規追加(#search-input, .search-input-dummy, 変数)
コントローラ/ヘルパ
app/controllers/stores_controller.rb, app/controllers/home_controller.rb, app/helpers/stores_helper.rb
StoresController#index を追加(id,name,lat,lon,open_time,address,tel を含む JSON を返す)。HomeController は再インデントのみ。StoresHelper を追加(空)
フロント(地図)
app/javascript/controllers/maps_controller.js
getStores() を追加し valibot の StoreSchema で検証、stores 配列を保持してマーカー生成/更新を行う。静的 values(ecoIconUrl, foodshareIconUrl, isCompany, companyRestrictionMessage)追加。マーカー削除ヘルパ等のリファクタ多数。JSDoc/型注釈更新
ビュー(フッター検索)
app/views/shared/_footer.html.erb
単独ボタンを form_with (GET, stores_path) の検索フォームに置換、左右画像とダミー幅要素を追加
ルーティング
config/routes.rb
トップレベルに resources :stores を追加
DB マイグレーション / スキーマ
db/migrate/20251009221009_add_tel_to_stores.rb, db/schema.rb
stores テーブルに tel:string カラムを追加
シード処理
db/seeds.rb, db/seeds/stores/*
複数 JSON ファイルを列挙・パース・検証し、重複/欠落を扱いながら Store レコードを作成する新ワークフローへ置換(日本語サマリ/警告出力)
旧インポート削除
lib/tasks/import_stores.rake
udon_list.json を処理する rake タスクを削除
テスト / フィクスチャ
test/controllers/stores_controller_test.rb, test/fixtures/stores.yml, test/system/measurements_test.rb
Stores コントローラ用テスト枠追加(雛形)。fixtures に lat/lon/open_time/tel を追加。system テストでボタン→input クリックに修正。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Browser
  participant MapsJS as MapsController(JS)
  participant Rails as Rails Router
  participant StoresCtrl as StoresController#index
  participant DB

  User->>Browser: ページ表示
  Browser->>MapsJS: Stimulus connect
  MapsJS->>Rails: GET /stores
  Rails->>StoresCtrl: ルーティング
  StoresCtrl->>DB: SELECT stores (id,name,lat,lon,open_time,address,tel)
  DB-->>StoresCtrl: レコード
  StoresCtrl-->>MapsJS: JSON 配列
  MapsJS->>MapsJS: StoreSchema で検証(valibot)
  MapsJS->>Browser: マーカー生成/更新
Loading
sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Rails as Rails (db:seed)
  participant FS as FileSystem
  participant JSON as JSON Parser
  participant DB

  Dev->>Rails: rails db:seed
  Rails->>FS: enumerate db/seeds/stores/**/*.json
  loop 各ファイル
    Rails->>JSON: parse file
    JSON-->>Rails: entries[]
    loop 各エントリ
      Rails->>Rails: validate/normalize fields (name,address,lat,lon,tel,open_time)
      Rails->>DB: check existence (coords OR name+address)
      alt not exists
        Rails->>DB: INSERT store (lat,lon,name,address,open_time?,tel?)
      else
        Rails->>Rails: skip & collect warning
      end
    end
  end
  Rails-->>Dev: 日本語の作成/スキップ/警告サマリ
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • anmoti

Poem

ぴょんと跳んだら API の畑
JSON の種で 店舗がはたけ
マーカー光る、にんじん印で呼ぶ
TEL も添えて、地図は踊るよ — ぴょん🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning タイトル「fix: rollback」は本プルリクエストの主要な変更を適切に表しておらず、内容と乖離しています。このPRではJSONベースの店舗シード導入やStoresControllerの追加、検索バーの統合など複数の新機能とリファクタリングを含んでいます。そのため、タイトルは変更セットの重要なポイントを簡潔に要約できていません。 タイトルを本PRの主な変更(JSONベースの店舗シード導入、StoresController APIの追加、フッター検索バー統合など)を反映する具体的かつ簡潔な文に修正してください。例えば「Add JSON-based store seeding, StoresController API, and footer search bar」のような形が適切です。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-dev-branch

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 126ff59 and 0a6e499.

📒 Files selected for processing (2)
  • app/controllers/home_controller.rb (2 hunks)
  • test/system/measurements_test.rb (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/controllers/home_controller.rb
🔇 Additional comments (1)
test/system/measurements_test.rb (1)

86-91: LGTM! UIの変更に正しく対応しています。

ボタン要素から input[type=submit] 要素への変更に適切に対応しています。コメントも明確で、変更理由が理解しやすくなっています。


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/assets/stylesheets/main.scss (1)

350-365: フォームに幅60pxが強制され検索バーがはみ出す—検索用クラスを追加して解消

.form に footer__button を使うと width: 60px が当たり、検索バー(150px)がレイアウト崩れします。検索専用のクラスを追加して幅を自動に。

 .footer {
   &__container {
@@
   }

   &__button {
     @extend %button-reset;
     @include flexbox($justify: center, $align: center);
     width: 60px;
   }
+
+  &__search {
+    @extend %button-reset;
+    @include flexbox($justify: center, $align: center);
+    width: auto;
+  }
 }

ビュー側では form の class を footer__search に変更(別コメントのdiff参照)。

🧹 Nitpick comments (9)
app/helpers/stores_helper.rb (1)

1-2: 空のヘルパーは不要なら削除、または直近で使う予定のヘルパーを追加

現状未使用です。将来追加予定がなければ削除して差分ノイズを減らすと良いです。

app/assets/stylesheets/main.scss (1)

369-378: アセットパイプライン連携のため background-image は image-url を推奨

fingerprint対応・CDN配信互換のため、SCSS内では image-url を使うと安全です。

-    background-image: url("search-bar-center.png");
+    background-image: image-url("search-bar-center.png");

Sprockets/Sass-Rails を使用している前提です。別ツールチェーンの場合は相応のヘルパ(asset-url 等)へ調整ください。

app/javascript/controllers/maps_controller.js (1)

36-57: サーバが返す shareInfo をスキーマに含めて明示対応(表示欠落のリスク回避)

コード全体で shop.shareInfo を参照していますが、StoreSchema に定義がありません。バリデーションで未知キーが削除・無視される場合、表示が崩れます。オプショナルで良いので schema に追加を推奨。

 const StoreSchema = v.object({
   id: v.number(),
   name: v.string(),
   lat: v.number(),
   lon: v.number(),
   open_time: v.nullable(
@@
   address: v.string(),
   eco: v.boolean(),
   foodshare: v.boolean(),
   tel: v.nullable(v.string()),
+  shareInfo: v.optional(
+    v.object({
+      itemName: v.string(),
+      description: v.string(),
+      takeDownTime: v.string(),
+    })
+  ),
 });

valibot の object 振る舞い(未知キーの保持/破棄)に依存します。現在のランタイムで unknown keys が保持されるかをご確認ください。保持されない場合は上記追加が必須です。

config/routes.rb (1)

27-28: API用途ならエンドポイントを絞り JSON をデフォルトに

不要なCRUDを公開しないために index のみに限定し、JSON既定化を推奨。フロントからの取得安定性も向上します。

-  resources :stores
+  resources :stores, only: [:index], defaults: { format: :json }

この変更により HTML 画面が必要な場合は別途ルートが必要です。UI上で /stores HTML を使う要件がないか確認してください。

.gitignore (1)

40-42: シード用ディレクトリをサブディレクトリごと明示的に無視する

将来の構成変更に強くするため、ワイルドカードを**にしておくと意図が明確になります(現状でも多くの場合は動きますが、明示が安心)。

-/db/seeds/stores/*
+/db/seeds/stores/**
 !/db/seeds/stores/.keep
test/fixtures/stores.yml (1)

2-10: open_time の表現が混在(プレーン文字列 vs JSON文字列)

フィクスチャ内で表現が異なるため、利用側のパースが不安定になります。どちらかに統一してください(例: すべてプレーン文字列として保存、または複雑な場合のみJSON化して保存し、API側でキー名を統一)。

フロントエンドが期待するキーとフォーマット(open_time か openTime、JSONか文字列)を確認お願いします。

Also applies to: 13-21

test/controllers/stores_controller_test.rb (1)

1-7: ダミーではなく /stores の統合テストを追加しましょう

基本的な200/JSON形状の検証を入れてリグレッションを防ぎましょう。

 require "test_helper"

 class StoresControllerTest < ActionDispatch::IntegrationTest
-  # test "the truth" do
-  #   assert true
-  # end
+  test "GET /stores returns stores JSON" do
+    get stores_url # resources :stores がある前提
+    assert_response :success
+
+    json = JSON.parse(response.body)
+    assert_kind_of Array, json
+    assert json.first.key?("id")
+    assert json.first.key?("name")
+    assert json.first.key?("lat")
+    assert json.first.key?("lon")
+    assert json.first.key?("address")
+    assert json.first.key?("tel")
+    # open_time か openTime のどちらを返すかはAPI仕様に合わせて調整
+  end
 end
README.md (1)

241-248: コマンド例の $ 先頭は外す(markdownlint: MD014)

lint回避のため、コマンド先頭の$は外すのが無難です。

-```bash
-$ rails db:seed
-```
+```bash
+rails db:seed
+```
app/controllers/stores_controller.rb (1)

4-13: 必要カラム取得と座標フィルタリング、JSONキーopen_time維持

  • .select(:id, :name, :lat, :lon, :open_time, :address, :tel).where.not(lat: nil, lon: nil)で不要データ排除
  • フロントがshop.open_timeを参照しているため、キーはsnake_caseのままに
app/controllers/stores_controller.rb
-  @stores = Store.all
+  @stores = Store
+              .select(:id, :name, :lat, :lon, :open_time, :address, :tel)
+              .where.not(lat: nil, lon: nil)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4532250 and 126ff59.

⛔ Files ignored due to path filters (5)
  • app/assets/images/search-bar-center.png is excluded by !**/*.png
  • app/assets/images/search-bar-left.png is excluded by !**/*.png
  • app/assets/images/search-bar-right.png is excluded by !**/*.png
  • app/assets/images/search-bar.png is excluded by !**/*.png
  • app/assets/images/search-btn.png is excluded by !**/*.png
📒 Files selected for processing (15)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • app/assets/stylesheets/main.scss (7 hunks)
  • app/controllers/home_controller.rb (0 hunks)
  • app/controllers/stores_controller.rb (1 hunks)
  • app/helpers/stores_helper.rb (1 hunks)
  • app/javascript/controllers/maps_controller.js (12 hunks)
  • app/views/shared/_footer.html.erb (1 hunks)
  • config/routes.rb (1 hunks)
  • db/migrate/20251009221009_add_tel_to_stores.rb (1 hunks)
  • db/schema.rb (1 hunks)
  • db/seeds.rb (1 hunks)
  • lib/tasks/import_stores.rake (0 hunks)
  • test/controllers/stores_controller_test.rb (1 hunks)
  • test/fixtures/stores.yml (1 hunks)
💤 Files with no reviewable changes (2)
  • app/controllers/home_controller.rb
  • lib/tasks/import_stores.rake
🧰 Additional context used
🧬 Code graph analysis (3)
app/controllers/stores_controller.rb (3)
app/controllers/home_controller.rb (3)
  • allow_unauthenticated_access (1-11)
  • index (6-34)
  • allow_unauthenticated_access (1-42)
app/controllers/admin/stores_controller.rb (3)
  • layout (1-67)
  • index (6-9)
  • select (11-15)
db/migrate/20251007000000_create_stores.rb (2)
  • change (1-15)
  • change (2-14)
app/helpers/stores_helper.rb (4)
app/helpers/admin/stores_helper.rb (1)
  • module Admin::StoresHelper (1-2)
app/helpers/application_helper.rb (1)
  • module ApplicationHelper (1-2)
db/migrate/20251007000000_create_stores.rb (2)
  • change (2-14)
  • change (1-15)
db/migrate/20251010163305_add_store_id_to_measurements.rb (1)
  • change (1-5)
db/seeds.rb (1)
app/javascript/controllers/maps_controller.js (1)
  • json (503-503)
🪛 markdownlint-cli2 (0.18.1)
README.md

247-247: Dollar signs used before commands without showing output

(MD014, commands-show-output)

🔇 Additional comments (3)
app/javascript/controllers/maps_controller.js (1)

501-509: JSONレスポンスは既に明示的に返されています
StoresController#indexrender json: を使用しているため、/stores へのリクエストでも常にJSONが返却されます。Acceptヘッダーや.json拡張子の指定は不要です。

db/schema.rb (1)

71-72: LGTM(tel カラムの追加)

スキーマ反映は問題ありません。

db/migrate/20251009221009_add_tel_to_stores.rb (1)

1-5: LGTM(tel の追加)

マイグレーションは簡潔で問題ありません。必要なら将来的にフォーマットバリデーションはモデル側で。

Comment thread app/views/shared/_footer.html.erb
Comment thread db/seeds.rb
Comment on lines +9 to +12
if files.empty?
puts "No seed files found to import (pattern=#{pattern})."
return
end
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.

⚠️ Potential issue | 🔴 Critical

seeds.rb の実行停止バグ(トップレベル return)と open_time の二重エンコード回避

  • Line 11 のトップレベルreturnrails db:seed実行時にLocalJumpErrorになり得ます。除去してください。
  • open_timeが文字列のときまでJSON.generateすると二重にクオートされた文字列が保存されます。型で分岐しましょう。
  • 警告メッセージの余分な)を削除。
 if files.empty?
   puts "No seed files found to import (pattern=#{pattern})."
-  return
 end
@@
-    attrs[:open_time] = JSON.generate(open_time) if open_time.present?
+    if open_time.present?
+      attrs[:open_time] = open_time.is_a?(String) ? open_time : JSON.generate(open_time)
+    end
     attrs[:tel] = tel if tel.present?
@@
-      warnings << "保存に失敗しました: #{file}) - #{name} #{store.errors.full_messages.join(', ')}"
+      warnings << "保存に失敗しました: #{file} - #{name} #{store.errors.full_messages.join(', ')}"

補足:

  • 全体をトランザクションで包むと途中失敗の整合性が上がります(任意)。

Also applies to: 81-83, 88-88

🤖 Prompt for AI Agents
In db/seeds.rb around lines 9-12 (also apply same fix pattern at 81-83 and 88),
remove the top-level `return` so `rails db:seed` won't raise LocalJumpError;
change the warning print to remove the extra closing parenthesis; and when
writing `open_time`, avoid double-encoding by only calling `JSON.generate` if
the value is not already a String (branch on the value's class and otherwise use
it directly). Optionally, wrap the seed import loop in a transaction to ensure
atomicity on partial failures.

@Desert-sabaku Desert-sabaku self-assigned this Oct 11, 2025
@Desert-sabaku
Copy link
Copy Markdown
Collaborator Author

@anmoti 良いならマージを

@Desert-sabaku
Copy link
Copy Markdown
Collaborator Author

ダメやこれ地図のピン出えへんわ

@Desert-sabaku
Copy link
Copy Markdown
Collaborator Author

@anmoti 俺ではどうしていいかよくわからん 多分ロールバック処理自体ミスってるんでこのPRはcloseで
さっき自分の方でも試してみるって言いよったよな? それで作った環境で頼むわ

@Desert-sabaku
Copy link
Copy Markdown
Collaborator Author

時間ねえぞ

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