From 8478f9c3b42056a293be1ce45484c036aebb3470 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 7 Mar 2019 11:27:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?member=5Fcount=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/subject.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/subject.rb b/app/models/subject.rb index 4388839c..c416974e 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -39,6 +39,10 @@ class Subject < ActiveRecord::Base count end + def member_count + self.shixuns.map(&:myshixuns_count).sum + end + def subject_shixuns count = 0 self.stage_shixuns.each do |stage_shixun| From c9d91b02d319538b0da2327744039d91a8ed570c Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 7 Mar 2019 11:32:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?averge=5Fstar=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 731a3741..f147b9b2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -321,9 +321,9 @@ class ShixunsController < ApplicationController @search_name = "#{sub.name} / #{tag.name}" end shixun_id = ShixunTagRepertoire.where(:tag_repertoire_id => tag).map(&:shixun_id) - @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text]).where(:id => shixun_id, :hidden => 0).includes(:challenges, :schools, :shixun_members, :users).order("status = 2 desc, publish_time asc") + @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text, :averge_star]).where(:id => shixun_id, :hidden => 0).includes(:challenges, :schools, :shixun_members, :users).order("status = 2 desc, publish_time asc") else - @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text]).where(:hidden => 0).includes(:challenges, :schools, :shixun_members, :users).order("status = 2 desc, publish_time asc") + @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text, :averge_star]).where(:hidden => 0).includes(:challenges, :schools, :shixun_members, :users).order("status = 2 desc, publish_time asc") end # # 依据tag和语言推荐实训,如果tag不够,则依据语言推荐;语言不够,则取系统的三个 # @recommend_shixuns = Shixun.find_by_sql("select challenge_id from challenge_tags where name like