Skip to content

お問い合わせ一覧と個別ページに「対応済」スタンプを実装#8535

Merged
komagata merged 10 commits intomainfrom
feature/add-completed-stamp
Jul 2, 2025
Merged

お問い合わせ一覧と個別ページに「対応済」スタンプを実装#8535
komagata merged 10 commits intomainfrom
feature/add-completed-stamp

Conversation

@riq0h
Copy link
Copy Markdown
Contributor

@riq0h riq0h commented Apr 6, 2025

Issue

#8465

概要

管理者画面のお問い合わせ一覧と個別ページに「対応済」スタンプを付けられるように実装しました。

変更確認方法

  1. feature/add-completed-stampをローカルに取り込む。
     ・git fetch origin feature/add-completed-stamp
     ・git checkout feature/add-completed-stamp
  2. foreman start -f Procfile.devで開発環境を立ち上げる。
     ・ユーザー名komagata、パスワードtesttestでログインする。
  3. 任意のお問い合わせページにアクセスして「対応済にする」ボタンが表示されているか確認する。
  4. 「対応済にする」ボタンをクリックしてブラウザをリロード後、同ページに「対応済」スタンプが表示されているか確認する。(注:リアルタイムでスタンプが表示されないのは仕様です。ミーティングで了承済み。)
  5. お問い合わせ一覧ページに移動して、「対応済にする」ボタンを押したページの項目に「対応済」スタンプが表示されているか確認する。

Screenshot

変更前

2025-04-06_10-37

変更後

2025-04-06_10-21

2025-04-06_10-21_1

2025-04-06_10-22

Summary by CodeRabbit

  • 新機能

    • 管理者画面の問い合わせ詳細ページに「対応済」スタンプと「確認者」表示を追加。
    • 問い合わせに「対応完了」状態を設定できるボタンを追加し、状態変更が可能に。
    • 問い合わせAPIに「対応完了」状態の更新エンドポイントを追加。
    • 問い合わせ一覧で「対応完了」状態の絞り込みが可能に。
  • UIの改善

    • 問い合わせ一覧・詳細で「対応済」や「確認者」などの視覚的インジケーターを表示。
  • パフォーマンス改善

    • 問い合わせ一覧の表示速度を最適化。
  • バグ修正

    • 一部関連データ取得時のエラーを防止。
  • 内部処理の改善

    • コードの可読性・保守性向上のためのリファクタリング。

@riq0h riq0h force-pushed the feature/add-completed-stamp branch from 38117be to 31c2ce1 Compare April 6, 2025 09:19
@riq0h riq0h requested a review from thmz337 May 2, 2025 08:38
@riq0h
Copy link
Copy Markdown
Contributor Author

riq0h commented May 2, 2025

@thmz337 お疲れ様です! ご都合が合えばレビューを行っていただけませんでしょうか? ご検討よろしくお願いします🙇

@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented May 2, 2025

ご指名ありがとうございます!
確認させていただきますね。

@komagata
Copy link
Copy Markdown
Member

@thmz337 二週間ほど経過していますがこちらのレビューいかがでしょうか。
もし厳しければ他の方に代わりにレビューをお願いしても大丈夫です〜

@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented May 14, 2025

@komagata

ご連絡ありがとうございます。
なかなか時間が取れずすいません。
今週の土日までにはと考えていますが、
もし難しそうであれば、他の方にご依頼させていただきます🙇

@komagata
Copy link
Copy Markdown
Member

@thmz337

@riq0h さんとコミュニケーションを取り合って決めてみて下さい〜

@riq0h
Copy link
Copy Markdown
Contributor Author

riq0h commented May 15, 2025

@thmz337 僕の方はそのスケジュール感でまったく問題ありません🙏 引き続きよろしくお願いします🙇

@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented May 15, 2025

@riq0h
ありがとうございます🙇🫠
ご迷惑おかけしますが、よろしくお願いします。

before_action :set_article, only: %i[show edit update destroy]
skip_before_action :require_active_user_login, raise: false, only: %i[index show]
before_action :require_admin_or_mentor_login, except: %i[index show]
before_action -> { require_admin_or_mentor_login if params[:tag] }, only: %i[index]
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.

こちらの変更点について、今回の修正と関係があるものなのでしょうか。

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.

多くのgemのバージョンが上がっていますが、問題なかったでしょうか。

# frozen_string_literal: true

class API::InquiriesController < API::BaseController
def index
Copy link
Copy Markdown
Contributor

@thmz337 thmz337 May 18, 2025

Choose a reason for hiding this comment

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

indexメソッドは使用されていますでしょうか。

end

create_table "categories", id: :serial, force: :cascade do |t|
t.string "name", limit: 255
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.

「limit: 255」が軒並み消えていますが、問題ないでしょうか。


def receiver
checkable.user
checkable.respond_to?(:user) ? checkable.user : nil
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.

checkableにuserメソッドが実装されていない場合、nilが返されるので、変更する必要がない気がします。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

inquiry.rbにuserメソッドを実装するか、ここで明示的にnilを返す形にしないと以下のようにNoMethodErrorが発生してしまうため加えています。両方を実装していたのは余計でした。
NoMethodError (undefined method user' for #<Inquiry id: 657618196, name: "inquiry2", email: "inquiry2@example.com", body: "お問い合わせのテスト2です。", created_at: "2017-01-01 09:00:00.000000000 +0900", updated_at: "2025-05-18 18:46:10.031782079 +0900", action_completed: true>): 18:46:10 rails.1 | 18:46:10 rails.1 | app/models/check.rb:13:in receiver'
18:46:10 rails.1 | app/models/check_callbacks.rb:5:in after_create' 18:46:10 rails.1 | app/controllers/api/inquiries_controller.rb:8:in update'

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.

確認したところ、おっしゃる通りでした。失礼しました。
こちらで問題ないかと思います。

class CheckCallbacks
def after_create(check)
if check.sender != check.receiver && check.checkable_type != 'Report'
if check.receiver && check.sender != check.receiver && check.checkable_type != 'Report' && check.checkable_type != 'Inquiry'
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.

Inquiryにおいてはreceiverがnilを返すので、check.checkable_type != 'Inquiry'まで到達しないと考えます。
よって不要ではないでしょうか。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

これがないと以下のようにバリデーションが失敗してしまうんですよね……。
GoodJob::Execution Update (0.5ms) UPDATE "good_jobs" SET "finished_at" = $1, "error" = $2, "updated_at" = $3 WHERE "good_jobs"."id" = $4 [["finished_at", "2025-05-18 09:38:01.802638"], ["error", "ActiveRecord::RecordInvalid: バリデーションに失敗しました: Userを入力してください"], ["updated_at", "2025-05-18 09:38:01.802908"], ["id", "d3dcf657-7967-45a5-b92d-c9066330beb4"]]

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.

バリデーションが失敗するのはどのような操作を行なった時になりますでしょうか?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

対応済みボタンを押した際です。

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.

&& check.checkable_type != 'Inquiry'の箇所を削除して対応済みボタンを押したのですが、
問題なさそうです。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

あれ? 本当ですね……ではこの点はすぐに修正し、pushいたします。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@thmz337 pushしたのでご確認をお願いします🙇

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.

@riq0h

修正ありがとうございます。
確認し問題ございませんでした。

scope :action_completed, -> { where(action_completed: true) }
scope :not_completed, -> { where(action_completed: false) }

def user
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.

app/models/check.rbのrecieverメソッドで、こちらのuserメソッドを実装する・しないに関わらずnilを返すので、
不要な気がしますがいかがでしょうか。

@thmz337
Copy link
Copy Markdown
Contributor

thmz337 commented May 18, 2025

@riq0h

お疲れ様です。レビュー遅くなってしまい、申し訳ございませんでした。
何点かコメントさせていただきましたので、ご確認お願いいたします。

@thmz337 thmz337 closed this May 18, 2025
@thmz337 thmz337 reopened this May 18, 2025
@riq0h riq0h force-pushed the feature/add-completed-stamp branch 6 times, most recently from 0e7de8b to 0d46255 Compare May 19, 2025 02:35
@riq0h
Copy link
Copy Markdown
Contributor Author

riq0h commented May 19, 2025

@thmz337 お疲れ様です! ご指摘いただいた不適切な箇所は削除し、そうでないと思われる箇所については返信を行いました🙏 お手隙の際に再度のレビューをよろしくお願いします🙇

@riq0h riq0h requested a review from thmz337 May 22, 2025 12:57
@riq0h riq0h force-pushed the feature/add-completed-stamp branch from 0d46255 to fcc10d3 Compare May 22, 2025 13:01
This was referenced Dec 19, 2025
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.

4 participants