Skip to content

Conversation

@Miya096jp
Copy link
Contributor

@Miya096jp Miya096jp commented Nov 1, 2025

Issue

#9253

概要

  • Google拡張機能用のエンドポイントを作成しました。
  • #9102とDBにおいて依存関係があるため、このPRの作業ブランチは#9102のブランチにリベースしています。

作業フェーズ

👉Phase1: Google拡張クライアント用のAPIエンドポイントを作成 #9287
Phase2: BuzzのGoogleExtensionのUIを作成 #1
Phase3: GoogleExtensionとAPI連携

関連Issue

Buzzページのリニューアル#9102

動作確認準備

  1. feature/buzz-api-for-google-extensionをローカルに取り込む
git fetch origin feature/buzz-api-google-extension
git checkout feature/buzz-api-google-extension
  1. foreman start -f Procfile.devでサーバーを起動
  2. 管理者/メンターでログイン
  3. 検証ツールのApplication > cookieからbootcampのcookieをコピーして控える

動作確認

1~5のcurlコマンドをターミナルで実行し、それぞれのレスポンスに、指定の情報が含まれていることを確認してください。

必要に応じて最初にBuzzを削除:

irb(main):001:0> Buzz.delete_all

1. showアクションのテスト1(既存レコードがない場合)

curl -v --get --data-urlencode "url=https://docs.komagata.org/6319" http://localhost:3000/api/buzzes/lookup -b "_bootcamp_session=<cookie>"

レスポンス

  • HTTP/1.1 200 OK
  • {"exists":false}

2. createアクションのテスト1(新規登録)

curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"buzz": {"title": "buzz_api登録テスト", "url": "https://docs.komagata.org/6319", "published_at": "2025-10-26"}}' http://localhost:3000/api/buzzes -b "_bootcamp_session=<cookie>"

レスポンス
201 created

3. showアクションのテスト2(既存レコードがある場合)

curl -v --get --data-urlencode "url=https://docs.komagata.org/6319" http://localhost:3000/api/buzzes/lookup -b "_bootcamp_session=<cookieをペースト>"

レスポンス

  • 200 OK
  • {"exists":true,"buzz":{"id":1073191923,"created_at":"2025-11-02T14:47:02.079+09:00","updated_at":"2025-11-02T14:47:02.079+09:00","url":"https://docs.komagata.org/6319","title":"buzz_api登録テスト","published_at":"2025-10-26","memo":null}}%

4. createアクションのテスト2(更新)

curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"buzz": {"title": "buzz_api編集テスト", "url": "https://docs.komagata.org/6319", "published_at": "2025-10-30"}}' http://localhost:3000/api/buzzes -b "_bootcamp_session=<cookie>"

レスポンス

  • 200OK
  • titleとpublished_atが更新されていることを確認
{"buzz": {"title": "buzz_api編集テスト", "url": "https://docs.komagata.org/6319", "published_at": "2025-10-30"}}

5. destroyアクションのテスト

curl -v -X DELETE "http://localhost:3000/api/buzzes/destroy?url=https://docs.komagata.org/6319" -b "_bootcamp_session=<cookie>"

レスポンス
200OK

Summary by CodeRabbit

リリースノート

  • 新機能

    • 紹介・言及記事の閲覧ページを追加。年度別フィルタリングと月ごとのグループ化に対応しました。
    • メンター向け管理画面で、記事の登録・編集・削除が可能になりました。
    • 外部連携用APIエンドポイントを追加。
  • 変更

    • 紹介・言及記事ページのナビゲーションリンクを更新しました。

全件だと一部整形作業が必要なため
title, url, memo, published_atカラムを追加
fixturesのpublished_on -> published_atに変更
indexアクションの中身を追加。LPの紹介・言及記事ページに渡すインスタンス変数をセット。
get "buzzes/years/:year", to: "buzzes#index"...
coderadditaiの指摘
coderabbitaiの指摘でkaminariのpagenation前にorderメソッドを挿入
Mentor::BuzzesController#edit/update/delete作成
metnor/buzzes/_form.html.slimのurlフィールドをeditページに非表示
mentor/buzzes/edid.html.slimに削除ボタンを追加
title, url, published_atカラムにそれぞれ追加
他: 値取得失敗時に422返却・errorオブジェクトにメッセージを追加
@Miya096jp Miya096jp force-pushed the feature/buzz-api-google-extension branch from 18afc91 to 7511d5c Compare November 5, 2025 11:36
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end

def require_admin_or_mentor_login_for_api
Copy link
Member

Choose a reason for hiding this comment

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

こちらに書くほうがよいとおもいます。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@komagata

concernsに移動しました。

- destroyアクションのリソースをurlでクエリーするため
-
destroyアクションのelse句の構文エラーを修正し、正しく404が返却されるようにした
@@ -0,0 +1,17 @@
# frozen_string_literal: true

class API::Buzzes::LookupsController < API::BaseController
Copy link
Member

Choose a reason for hiding this comment

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

クラス名(リソース名)は名詞である必要があります。(メソッドが動詞)

@Miya096jp Miya096jp force-pushed the feature/redesign-buzzes-page branch 2 times, most recently from bc37e35 to 0ede869 Compare November 26, 2025 08:44
@Miya096jp Miya096jp force-pushed the feature/redesign-buzzes-page branch 15 times, most recently from 94fa768 to 791f465 Compare December 21, 2025 14:38
@Miya096jp Miya096jp force-pushed the feature/redesign-buzzes-page branch 3 times, most recently from b36e7d5 to d3e8f53 Compare December 22, 2025 06:57
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