部分课程资源创建时间不正确

This commit is contained in:
sw 2015-08-14 13:55:46 +08:00
parent 5cf6b7e76a
commit 35d6c76a8e
4 changed files with 36 additions and 23 deletions

View File

@ -1,22 +0,0 @@
class UpdateCourseActivityTime < ActiveRecord::Migration
def up
count = CourseActivity.all.count / 10 + 1
transaction do
for i in 1 ... count do i
CourseActivity.page(i).per(10).each do |activity|
if activity.course_act
if activity.course_act.respond_to?("created_at")
activity.created_at = activity.course_act.created_at
elsif activity.course_act.respond_to?("created_on")
activity.created_at = activity.course_act.created_on
end
activity.save
end
end
end
end
end
def down
end
end

View File

@ -0,0 +1,13 @@
class ChangeAttachmentTime < ActiveRecord::Migration
def up
Attachment.where("container_type = 'Course'").each do |attachment|
if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i
attachment.created_on = attachment.container.created_at + 3600 * 24
attachment.save
end
end
end
def down
end
end

View File

@ -0,0 +1,22 @@
class UpdateCourseActivityTime < ActiveRecord::Migration
def up
count = CourseActivity.all.count / 10 + 1
transaction do
for i in 1 ... count do i
CourseActivity.page(i).per(10).each do |activity|
if activity.course_act
if activity.course_act.respond_to?("created_at")
activity.created_at = activity.course_act.created_at
elsif activity.course_act.respond_to?("created_on")
activity.created_at = activity.course_act.created_on
end
activity.save
end
end
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150811083234) do
ActiveRecord::Schema.define(:version => 20150814031258) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false