From 7cc9d207b65249f4d354e67685fbc4728b365f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 8 Nov 2022 17:18:04 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2count=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 5 +++-- app/queries/projects/list_query.rb | 2 +- app/views/projects/index.json.jbuilder | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8bc2fb476..71e409dde 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -39,8 +39,9 @@ class ProjectsController < ApplicationController category_id = params[:category_id] @total_count = if category_id.blank? - ps = ProjectStatistic.first - ps.common_projects_count + ps.mirror_projects_count unless ps.blank? + # ps = ProjectStatistic.first + # ps.common_projects_count + ps.mirror_projects_count unless ps.blank? + @projects.total_count else cate = ProjectCategory.find_by(id: category_id) cate&.projects_count || 0 diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index b46ceb381..ec1dcda3c 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -17,7 +17,7 @@ class Projects::ListQuery < ApplicationQuery sort = params[:sort_by] || "updated_on" sort_direction = params[:sort_direction] || "desc" - collection = optimize_sorting(collection, sort) if params[:category_id].present? + # collection = optimize_sorting(collection, sort) if params[:category_id].present? custom_sort(collection, sort, sort_direction) # scope = scope.reorder("projects.#{sort} #{sort_direction}") diff --git a/app/views/projects/index.json.jbuilder b/app/views/projects/index.json.jbuilder index 874f60974..31d0db9c5 100644 --- a/app/views/projects/index.json.jbuilder +++ b/app/views/projects/index.json.jbuilder @@ -1,4 +1,4 @@ -json.total_count @projects.total_count +json.total_count @total_count json.projects @projects do |project| # json.partial! "/projects/project_detail", project: project json.id project.id @@ -22,7 +22,7 @@ json.projects @projects do |project| project_educoder = project.project_educoder json.name project_educoder&.owner json.login project_educoder&.repo_name.split('/')[0] - json.image_url render_educoder_avatar_url(project.project_educoder) + # json.image_url render_educoder_avatar_url(project.project_educoder) else user = project.owner json.type user.type