diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index ffc548cd..d8534012 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -373,7 +373,7 @@ class ForumSectionsService page = params[:page].to_i > 0 ? (params[:page].to_i - 1) : 0 offset = page * LIMIT - memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq + # memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: true, parent_id: nil, id: memo_forum_section_ids).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})").order("created_at desc") @@ -415,7 +415,7 @@ class ForumSectionsService return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id]) select_section_ids = [params[:id]] - unless @forum_section.parent_id.present? + # unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums # end @@ -427,7 +427,8 @@ class ForumSectionsService offset = page * LIMIT #全部的父帖子 parent_memos_ids = Memo.where(parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})").pluck(:id).uniq - memos_all = Memo.where(hidden:true,published_at: nil, parent_id: parent_memos_ids).order("created_at ASC") + # memos_all = Memo.where(hidden:true,published_at: nil, parent_id: parent_memos_ids).order("created_at ASC") + memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") memos_count = memos_all.size memos = memos_all.limit(LIMIT).offset(offset) @@ -472,7 +473,7 @@ class ForumSectionsService offset = page * LIMIT #全部的父帖子 - memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq + # memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq memos_all = Memo.where(hidden: false,parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: false, parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})") if params[:type].present?