统一课程动态和作业的更新时间
This commit is contained in:
parent
2a55d8f0c3
commit
6d32e812aa
|
@ -0,0 +1,24 @@
|
|||
class UpdateActivity < ActiveRecord::Migration
|
||||
def up
|
||||
homeworks = HomeworkCommon.where("course_id = 342")
|
||||
unless homeworks.nil?
|
||||
homeworks.each do |h|
|
||||
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", 'HomeworkCommon', h.id).first
|
||||
user_activity = UserActivity.where("act_type=? and act_id =?", 'HomeworkCommon', h.id).first
|
||||
org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", 'HomeworkCommon', h.id).first
|
||||
if course_activity && h.updated_at > course_activity.updated_at
|
||||
course_activity.update_column('updated_at', h.updated_at)
|
||||
end
|
||||
if user_activity && h.updated_at > user_activity.updated_at
|
||||
user_activity.update_column('updated_at', h.updated_at)
|
||||
end
|
||||
if org_activity && h.updated_at > org_activity.updated_at
|
||||
org_activity.update_column('updated_at', h.updated_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160506104128) do
|
||||
ActiveRecord::Schema.define(:version => 20160509025404) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue