[サイト内検索] 隠しページ(ページ管理>メニュー非表示のページ)は検索に含めない設定を追加#2386
Open
akagane99 wants to merge 1 commit intoopensource-workshop:masterfrom
Open
[サイト内検索] 隠しページ(ページ管理>メニュー非表示のページ)は検索に含めない設定を追加#2386akagane99 wants to merge 1 commit intoopensource-workshop:masterfrom
akagane99 wants to merge 1 commit intoopensource-workshop:masterfrom
Conversation
masaton0216
requested changes
Mar 25, 2026
Contributor
masaton0216
left a comment
There was a problem hiding this comment.
ご対応ありがとうございます。
下記、ご確認お願いいたします。
- パフォーマンス観点で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'); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
下記部分は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(); |
Contributor
There was a problem hiding this comment.
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) { |
Contributor
There was a problem hiding this comment.
マジックナンバーがコントローラ/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(); |
Contributor
There was a problem hiding this comment.
イコール演算子の右側にスペースが2つ続いています。
$frame_page_ids = Frame::whereIn(...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
narrow_down_labelは既に削除済みカラムだったため、$fillableから消しました。修正後画面
サイト内検索>設定変更(新規作成)
レビュー完了希望日
急ぎません
関連Pull requests/Issues
なし
参考
なし
DB変更の有無
あり
チェックリスト