新增消息迁移

This commit is contained in:
huang 2015-08-30 11:20:37 +08:00
parent 7ed93c1d80
commit e652e92217
4 changed files with 39 additions and 33 deletions

View File

@ -155,7 +155,7 @@ class UsersController < ApplicationController
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc")
@message_alls_count = @message_alls.count
when 'issue'
@message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).reverse
@message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc")
@message_alls_count = @message_alls.count
when 'issue_update' # 缺陷状态更新、留言
@message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc")

View File

@ -44,7 +44,7 @@
<%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id },
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{ma.course_message.title}" %></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "Comment" %>
@ -55,7 +55,7 @@
<%= link_to ma.course_message.comments.html_safe, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id },
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{ma.course_message.comments.html_safe}" %></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "HomeworkCommon" %>
@ -64,7 +64,7 @@
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布了作业:</span></li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),:class => "newsGrey", :title => "#{ma.course_message.name}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_at).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "Poll" %>
@ -75,7 +75,7 @@
<%= link_to format_activity_title(" #{ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name}"), poll_path(ma.course_message.id),
:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{ma.course_message.polls_name}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_at).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "Message" %>
@ -86,7 +86,7 @@
<%=link_to ma.course_message.subject.html_safe, course_boards_path(ma.course_message.course,:parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id,
:topic_id => ma.course_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{ma.course_message.subject.html_safe}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
@ -98,7 +98,7 @@
<% unless ma.content.nil? %>
<%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.content.html_safe}" %></a></li>
<% end %>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_at).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "JournalsForMessage" %>
@ -107,7 +107,7 @@
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了作品评论:</span></li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.course_message.notes}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.course_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>
@ -125,7 +125,7 @@
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.forge_message.subject, issue_path(:id => ma.forge_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ma.forge_message.subject}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.forge_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "Journal" %>
@ -143,7 +143,7 @@
issue_path(:id => ma.forge_message.journalized_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{get_issue_des_update(ma.forge_message).html_safe}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.forge_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "Message" %>
@ -156,7 +156,7 @@
:parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id,
:topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{ma.forge_message.subject.html_safe}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.forge_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "News" %>
@ -171,7 +171,7 @@
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ("#{ma.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ma.forge_message.id}, :class => "newsGrey", :title => "#{ma.forge_message.title.html_safe}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.forge_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "Comment" %>
@ -182,7 +182,7 @@
<li class="homepageNewsContent fl">
<%= link_to "#{ma.forge_message.comments.html_safe}",
{:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.forge_message.comments.html_safe}"%></li>
<li class="homepageNewsTime fl"><%= time_tag(ma.forge_message.created_on).html_safe %> </li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>

View File

@ -19,26 +19,6 @@ class UpdateMessageTime < ActiveRecord::Migration
end
end
end
forge_count = ForgeMessage.all.count / 30 + 1
transaction do
for i in 1 ... forge_count do i
ForgeMessage.page(i).per(30).each do |fmessage|
if fmessage.forge_message
if fmessage.forge_message.respond_to?("created_at")
fmessage.created_at = fmessage.forge_message.created_at
elsif fmessage.forge_message.respond_to?("created_on")
fmessage.created_at = fmessage.forge_message.created_on
end
fmessage.save
forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first
forge_all_message.created_at = fmessage.created_at
forge_all_message.save
end
end
end
end
end
def down

View File

@ -0,0 +1,26 @@
class UpdateForgeMessageTime < ActiveRecord::Migration
def up
forge_count = ForgeMessage.all.count / 30 + 1
transaction do
for i in 1 ... forge_count do i
ForgeMessage.page(i).per(30).each do |fmessage|
if fmessage.forge_message
if fmessage.forge_message.respond_to?("created_at")
fmessage.created_at = fmessage.forge_message.created_at
elsif fmessage.forge_message.respond_to?("created_on")
fmessage.created_at = fmessage.forge_message.created_on
end
fmessage.save
forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first
forge_all_message.created_at = fmessage.created_at
forge_all_message.save
end
end
end
end
end
def down
end
end