From ce105b4c07e76c3566bb4065dc735278fc56d639 Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Fri, 26 Feb 2021 16:20:26 +0800 Subject: [PATCH] [FIX]project category not include private repo --- app/controllers/project_categories_controller.rb | 4 +++- app/views/project_categories/group_list.json.jbuilder | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/project_categories_controller.rb b/app/controllers/project_categories_controller.rb index c6c2cd21..714089e7 100644 --- a/app/controllers/project_categories_controller.rb +++ b/app/controllers/project_categories_controller.rb @@ -6,6 +6,8 @@ class ProjectCategoriesController < ApplicationController end def group_list - @project_categories = ProjectCategory.where('projects_count > 0').order(projects_count: :desc) + # @project_categories = ProjectCategory.where('projects_count > 0').order(projects_count: :desc) + @project_categories = ProjectCategory.eager_load(:projects) + .where(projects: {is_public: true}) end end diff --git a/app/views/project_categories/group_list.json.jbuilder b/app/views/project_categories/group_list.json.jbuilder index f13d6ecf..8d5a9231 100644 --- a/app/views/project_categories/group_list.json.jbuilder +++ b/app/views/project_categories/group_list.json.jbuilder @@ -1,5 +1,6 @@ json.array! @project_categories do |category| json.id category.id json.name category.name - json.projects_count category.projects_count + # json.projects_count category.projects_count + json.projects_count category.projects.size end