##// END OF EJS Templates
scm: git: performance improvements in fetching revisions (#8857, #9472)...
scm: git: performance improvements in fetching revisions (#8857, #9472) Parse a revision for a given branch, just if we haven't parsed it for any branches before. Moved the db check to for existing revisions into a grouped search. Search for many revisions at once: this reduces db load. Revisions are grouped into sets of 100. This is to improve memory consumption. There will be just one query instead of each 100. The above two methods significantly increase parsing speed. Test case was a git repo with 6000+ commits on a master branch, and several other branches originating for master. Speed improved from 1.4h to 18min. Contributed by Gergely Fábián. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9144 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9014:d0356fe93533
r9024:999a4ba30d7b
Show More
news.rb
66 lines | 2.5 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Fixed: Latest news appear on the homepage for projects with the News module disabled (#1941)....
r1908 # Redmine - project management software
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 # Copyright (C) 2006-2011 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class News < ActiveRecord::Base
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a news (#10390)....
r9014 include Redmine::SafeAttributes
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 belongs_to :project
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 validates_presence_of :title, :description
Jean-Philippe Lang
Added several validates_length_of...
r590 validates_length_of :title, :maximum => 60
validates_length_of :summary, :maximum => 255
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663
Jean-Philippe Lang
Allows attachments on news (#1972)....
r8608 acts_as_attachable :delete_permission => :manage_news
Jean-Philippe Lang
Fixed: News summary field is not searchable (#2998)....
r2552 acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663 acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 acts_as_activity_provider :find_options => {:include => [:project, :author]},
:author_key => :author_id
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 acts_as_watchable
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 after_create :add_author_as_watcher
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
named_scope :visible, lambda {|*args| {
Jean-Philippe Lang
Refactor and add tests for News #index API (#7072)....
r4391 :include => :project,
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
Jean-Philippe Lang
Refactor and add tests for News #index API (#7072)....
r4391 }}
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Prevent mass-assignment when adding/updating a news (#10390)....
r9014 safe_attributes 'title', 'summary', 'description'
Jean-Philippe Lang
Make sure users don't get notified for thing they can not view (#3589)....
r3055 def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_news, project)
end
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds a News#commentable? method to easily specific additional rules....
r8734 # Returns true if the news can be commented by user
def commentable?(user=User.current)
user.allowed_to?(:comment_news, project)
end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # returns latest news for projects visible by user
Jean-Philippe Lang
Fixed: Latest news appear on the homepage for projects with the News module disabled (#1941)....
r1908 def self.latest(user = User.current, count = 5)
Toshi MARUYAMA
code layout clean up app/models/news.rb...
r8393 find(:all, :limit => count,
:conditions => Project.allowed_to_condition(user, :view_news),
:include => [ :author, :project ],
:order => "#{News.table_name}.created_on DESC")
Jean-Philippe Lang
Localization plugin removed (replaced with GLoc)...
r12 end
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 private
Toshi MARUYAMA
remove trailing white-spaces from news model source....
r5699
Jean-Philippe Lang
Adds email notifications support for news comments (#2074)....
r4883 def add_author_as_watcher
Watcher.create(:watchable => self, :user => author)
end
Jean-Philippe Lang
Initial commit...
r2 end