From 591ad35b05cd096a08d5d4ce5e103f48c27ba28c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 17 Dec 2019 16:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=8F=B3=E4=BE=A7=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 5 +++-- app/views/shixuns/_right.json.jbuilder | 12 +++++++++--- app/views/shixuns/show_right.json.jbuilder | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index afffb9963..aa25d0875 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -165,9 +165,10 @@ class ShixunsController < ApplicationController def show_right owner = @shixun.owner - #@fans_count = owner.fan_count - #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count + @user_tags = @shixun.user_tags_name(current_user) + @shixun_tags = @shixun.challenge_tags_name + @myshixun = @shixun.myshixuns.find_by(user_id: current_user.id) end # 排行榜 diff --git a/app/views/shixuns/_right.json.jbuilder b/app/views/shixuns/_right.json.jbuilder index e6f839aa5..751172701 100644 --- a/app/views/shixuns/_right.json.jbuilder +++ b/app/views/shixuns/_right.json.jbuilder @@ -13,11 +13,17 @@ json.recommands do json.partial! 'shap_shixun', locals: { shixuns: shixun.relation_path.size > 0 ? recommend_shixun(shixun) : [] } end +if shixun.status > 1 + json.complete_count @myshixun&.passed_count + json.challenge_count @shixun.challenges_count +end + # 技能标签 -user_tags = shixun.user_tags_name(User.current) json.tags do - json.array! shixun.challenge_tags_name do |tag| + json.array! @shixun_tags do |tag| json.tag_name tag - json.status user_tags.include?(tag) + json.status @user_tags.include?(tag) end end +json.tag_count @shixun_tags.size +json.user_tag_count @user_tags.size diff --git a/app/views/shixuns/show_right.json.jbuilder b/app/views/shixuns/show_right.json.jbuilder index fe3c5d0f5..694bd4e7d 100644 --- a/app/views/shixuns/show_right.json.jbuilder +++ b/app/views/shixuns/show_right.json.jbuilder @@ -1,6 +1,6 @@ json.partial! 'shixuns/right', locals: { shixun: @shixun } -json.follow follow?(@shixun.owner, User.current) -json.fans_count @fans_count -json.followed_count @followed_count +# json.follow follow?(@shixun.owner, User.current) +# json.fans_count @fans_count +# json.followed_count @followed_count json.user_shixuns_count @user_own_shixuns