From 0a18f365abde9c13f323579dda6c80a2252f8f4e Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 5 Mar 2016 08:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=9A=84=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ibutor.rb => 20160304234903_uodapte_contributor_course.rb} | 4 ++-- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename db/migrate/{20160304200639_update_contributor.rb => 20160304234903_uodapte_contributor_course.rb} (91%) diff --git a/db/migrate/20160304200639_update_contributor.rb b/db/migrate/20160304234903_uodapte_contributor_course.rb similarity index 91% rename from db/migrate/20160304200639_update_contributor.rb rename to db/migrate/20160304234903_uodapte_contributor_course.rb index d90699b91..e0f86550d 100644 --- a/db/migrate/20160304200639_update_contributor.rb +++ b/db/migrate/20160304234903_uodapte_contributor_course.rb @@ -1,4 +1,4 @@ -class UpdateContributor < ActiveRecord::Migration +class UodapteContributorCourse < ActiveRecord::Migration def up Course.all.each do |course| if course.course_activities.count > 1 @@ -21,7 +21,7 @@ class UpdateContributor < ActiveRecord::Migration # 课程留言数 journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.user_id, course.id, "Course").count * 1 # 作业留言 - journal_homework_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.user_id, course.id, "HomeworkCommon").count * 1 + journal_homework_count = JournalsForMessage.find_by_sql("SELECT jfm.* FROM `journals_for_messages` jfm, homework_commons hc where hc.id = jfm.jour_id and hc.course_id =#{course.id} and jfm.user_id =#{s.user_id} and jfm.jour_type ='HomeworkCommon';").count * 1 # journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1 # journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1 total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count diff --git a/db/schema.rb b/db/schema.rb index c21580c90..0fc14740c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160304154643) do +ActiveRecord::Schema.define(:version => 20160304200639) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false