From f9fc7f3eef22a6bba8067bb5c10e127c1c534eb6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 12 Feb 2020 16:49:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=8F=96=E5=AE=9E=E8=AE=AD=E4=BA=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/subject.rb | 4 ++++ app/views/weapps/subjects/show.json.jbuilder | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/subject.rb b/app/models/subject.rb index fc43cfb11..99ba4b72b 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -65,6 +65,10 @@ class Subject < ApplicationRecord excellent ? CourseMember.where(role: 4, course_id: courses.pluck(:id)).pluck(:user_id).length : shixuns.pluck(:myshixuns_count).sum end + def myshixuns_count + shixuns.pluck(:myshixuns_count).sum + end + def all_score subject_shixun_score + subject_shixun_choose_score end diff --git a/app/views/weapps/subjects/show.json.jbuilder b/app/views/weapps/subjects/show.json.jbuilder index 29a30a89a..476e3e797 100644 --- a/app/views/weapps/subjects/show.json.jbuilder +++ b/app/views/weapps/subjects/show.json.jbuilder @@ -3,7 +3,7 @@ json.subject do json.description @subject.description json.shixuns_count @subject.shixuns_count json.challenges_count @subject.subject_challenge_count - json.member_count @subject.member_count + json.member_count @subject.myshixuns_count json.subject_score @subject.all_score json.learning_notes @subject.learning_notes end