首页时间排序,可能会引起其他调用event_datetime的问题。待观察
This commit is contained in:
parent
e12922544a
commit
fea1cdff53
|
@ -79,6 +79,7 @@ class MessagesController < ApplicationController
|
|||
@reply.board = @board
|
||||
@reply.safe_attributes = params[:reply]
|
||||
@topic.children << @reply
|
||||
@topic.update_attribute(:updated_on, Time.now)
|
||||
if !@reply.new_record?
|
||||
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||||
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||||
|
|
|
@ -102,10 +102,21 @@ module WelcomeHelper
|
|||
end
|
||||
|
||||
def find_new_forum_topics limit=7
|
||||
Memo.where('memos.parent_id IS NULL').reorder('memos.created_at DESC').limit(limit)
|
||||
# Memo.where('memos.parent_id IS NULL').reorder('memos.created_at DESC').limit(limit)
|
||||
# activity = Redmine::Activity::Fetcher.new(nil)
|
||||
# activity.scope=['memos']
|
||||
# activity.events_welcome(nil, nil, {:limit => limit})
|
||||
|
||||
# resultSet = Memo.where('memos.parent_id IS NULL').includes(:last_reply).order('COALESCE (last_replies_memos.created_at, memos.created_at) DESC').limit(limit)
|
||||
# resultSet += Message.where('messages.parent_id IS NULL').includes(:last_reply).order('COALESCE (last_replies_messages.created_on, messages.created_on) DESC').limit(limit)
|
||||
resultSet = Memo.where('parent_id IS NULL').order('updated_at DESC').limit(limit)
|
||||
resultSet += Message.where('parent_id IS NULL').order('updated_on DESC').limit(limit)
|
||||
# resultSet = resultSet.to_a
|
||||
resultSet.sort! {|x,y| y.event_datetime <=> x.event_datetime}
|
||||
# for i in 0..(resultSet.size-1)
|
||||
# resultSet[i] = resultSet[i].parent if resultSet[i].parent
|
||||
# end
|
||||
resultSet.take(limit)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Forum < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC"
|
||||
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy
|
||||
has_many :memos, :dependent => :destroy
|
||||
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
|
||||
safe_attributes 'name',
|
||||
|
|
|
@ -17,7 +17,8 @@ class Memo < ActiveRecord::Base
|
|||
# #:project_key => "#{Forum.table_name}.project_id"
|
||||
# :date_column => "#{table_name}.created_at"
|
||||
acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
|
||||
:datetime => :created_at,
|
||||
:datetime => :updated_at,
|
||||
# :datetime => :created_at,
|
||||
:description => :content,
|
||||
:author => :author,
|
||||
:type => Proc.new {|o| o.parent_id.nil? ? 'Memo' : 'Reply'},
|
||||
|
|
|
@ -33,6 +33,7 @@ class Message < ActiveRecord::Base
|
|||
:date_column => "#{table_name}.created_on"
|
||||
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
||||
:description => :content,
|
||||
:datetime => :updated_on,
|
||||
# :datetime => "#{Message.table_name}.created_on",
|
||||
:group => :parent,
|
||||
:type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
||||
|
|
Loading…
Reference in New Issue