Project activities perfomance increased. Cache for project activitites disabled. Repository conception changed

This commit is contained in:
Dmitriy Zaporozhets 2012-01-04 08:17:41 +02:00
parent ac62036320
commit 0ebc610e49
10 changed files with 64 additions and 4 deletions

View file

@ -79,6 +79,7 @@ class Project < ActiveRecord::Base
:repo_exists?,
:commit,
:commits,
:commits_with_refs,
:tree,
:heads,
:commits_since,
@ -144,6 +145,10 @@ class Project < ActiveRecord::Base
users_projects.find_by_user_id(user_id)
end
def fresh_merge_requests(n)
merge_requests.includes(:project, :author).order("created_at desc").first(n)
end
def fresh_issues(n)
issues.includes(:project, :author).order("created_at desc").first(n)
end
@ -290,6 +295,16 @@ class Project < ActiveRecord::Base
end[0...n]
end
def updates_wo_repo(n=3)
[
fresh_issues(n),
fresh_merge_requests(n),
fresh_notes(n)
].compact.flatten.sort do |x, y|
y.created_at <=> x.created_at
end[0...n]
end
def check_limit
unless owner.can_create_project?
errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it")