Skip to content

[サイト内検索] 隠しページ(ページ管理>メニュー非表示のページ)は検索に含めない設定を追加#2386

Open
akagane99 wants to merge 1 commit intoopensource-workshop:masterfrom
akagane99:connect-cms-ideas/issues/183
Open

[サイト内検索] 隠しページ(ページ管理>メニュー非表示のページ)は検索に含めない設定を追加#2386
akagane99 wants to merge 1 commit intoopensource-workshop:masterfrom
akagane99:connect-cms-ideas/issues/183

Conversation

@akagane99
Copy link
Contributor

概要

修正後画面

サイト内検索>設定変更(新規作成)

image

レビュー完了希望日

急ぎません

関連Pull requests/Issues

なし

参考

なし

DB変更の有無

あり

チェックリスト

@masaton0216 masaton0216 self-requested a review March 25, 2026 01:47
@masaton0216 masaton0216 self-assigned this Mar 25, 2026
@masaton0216 masaton0216 added the enhancement 機能強化 label Mar 25, 2026
Copy link
Contributor

@masaton0216 masaton0216 left a comment

Choose a reason for hiding this comment

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

ご対応ありがとうございます。
下記、ご確認お願いいたします。

  • パフォーマンス観点で2つ
  • enum化の検討依頼1つ
  • スペース続きの軽微な修正1つ

Comment on lines 480 to +498
$pages = Page::get();

// ページの選択「ページ管理のメニュー表示条件に従う」
if ($searchs_frame->page_select == 1) {

// 表示ページのみに絞る
$pages = $pages->filter(function ($page) {
return $page->base_display_flag == 1;
});

// フレームの選択「選択したものだけ表示する」
if ($searchs_frame->frame_select == 1) {
// 選択したフレームに紐づくページ を追加取得してマージ
$frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))->get()->pluck('page_id')->toArray();
$pages_frame = Page::whereIn('pages.id', $frame_page_ids)->get();

$pages = $pages->merge($pages_frame)->unique('id');
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

下記部分はSQLにした方が走査処理としては効率的かと思いましたが、いかがでしょう?

      $pages = $pages->filter(function ($page) {                                                                                                                 
          return $page->base_display_flag == 1;                                                                                                                  
      });

全体を示すと下記のようなコードを想定しています。

      // ページの選択「ページ管理のメニュー表示条件に従う」
      if ($searchs_frame->page_select == 1) {                                                                                                                    
          // 表示ページのみをDBレベルで絞り込む
          $pages = Page::where('base_display_flag', 1)->get();                                                                                                   
                  
          // フレームの選択「選択したものだけ表示する」                                                                                                          
          if ($searchs_frame->frame_select == 1) {
              // 選択したフレームに紐づくページ を追加取得してマージ                                                                                             
              $frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))                                                      
                  ->pluck('page_id')->toArray();                                                                                                                 
              $pages_frame = Page::whereIn('pages.id', $frame_page_ids)->get();                                                                                  
                                                                                                                                                                 
              $pages = $pages->merge($pages_frame)->unique('id');
          }                                                                                                                                                      
      } else {    
          // 全ページを検索対象とする
          $pages = Page::get();
      } 

Comment on lines +493 to +494
$frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))->get()->pluck('page_id')->toArray();
$pages_frame = Page::whereIn('pages.id', $frame_page_ids)->get();
Copy link
Contributor

Choose a reason for hiding this comment

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

2回のDBクエリを1回に統合できそうです。

  $pages_frame = Page::whereIn('id', function ($query) use ($searchs_frame) {                                                                                    
      $query->select('page_id')                                                                                                                                  
          ->from('frames')
          ->whereIn('id', explode(',', $searchs_frame->target_frame_ids));                                                                                       
  })->get();  

$pages = Page::get();

// ページの選択「ページ管理のメニュー表示条件に従う」
if ($searchs_frame->page_select == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

マジックナンバーがコントローラ/viewに散在してしまっているので、enum定数化をお願いすること可能でしょうか?

(一案)
SearchsPageSelect.php
~略~
const ALL_PAGES = 0;           // 全て表示する                                                                                                                 
const MENU_VISIBLE_ONLY = 1;   // ページ管理のメニュー表示条件に従う

// フレームの選択「選択したものだけ表示する」
if ($searchs_frame->frame_select == 1) {
// 選択したフレームに紐づくページ を追加取得してマージ
$frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))->get()->pluck('page_id')->toArray();
Copy link
Contributor

Choose a reason for hiding this comment

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

イコール演算子の右側にスペースが2つ続いています。

$frame_page_ids =  Frame::whereIn(...)

@masaton0216 masaton0216 assigned akagane99 and unassigned masaton0216 Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 機能強化

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants