From 6cede3d2bead3b65d697e3e105225fb43f6826e5 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 4 Dec 2013 16:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=AF=84=E8=AE=BA=E6=95=B0?= =?UTF-8?q?=E9=87=8F=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=8C=89=E7=85=A7=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=9F=A5=E6=89=BEbug,etc...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/welcome_helper.rb | 12 ++++++++++++ app/models/memo.rb | 3 ++- .../lib/acts_as_activity_provider.rb | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 7b461cee0..5a103e015 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -47,6 +47,18 @@ module WelcomeHelper sort_contest_by_hot end + def cal_memos_count event + return nil if event.parent_id + event.replies_count + rescue NoMethodError + nil + end + + def cal_issues_count event + event.journals.count + rescue NoMethodError + nil + end def time_tag_welcome time diff --git a/app/models/memo.rb b/app/models/memo.rb index a06d8dcf5..f18037f04 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -23,7 +23,8 @@ class Memo < ActiveRecord::Base :type => Proc.new {|o| o.parent_id.nil? ? 'Forum' : 'Memo'}, :url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :anchor => "reply-#{o.id}"})} acts_as_activity_provider :author_key => :author_id, - :func => 'memos' + :func => 'memos', + :timestamp => 'created_at' # :find_options => {:type => 'memos'} # acts_as_watchable diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index 269a889df..bf53509f7 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -82,6 +82,9 @@ module Redmine scope.all(provider_options[:find_options].dup) end + # 为了首页获取数据基本复制了上面的方法,改变了用户查看权限,增加了对讨论区的识别。 + # 因为新建了讨论区的内容,没有与项目方法混合,但是 event_type 取值类型还在共用,可能会对项目活动取值性能造成影响 + # 不过鉴于项目参与查询的条件减少,而增加的时间没有可见增长,重写event_type 的类型需要设计到lib,暂时不做改动 def find_events1(event_type, user, from, to, options) provider_options = activity_provider_options[event_type] raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?