Project activities perfomance increased. Cache for project activitites disabled. Repository conception changed
This commit is contained in:
parent
ac62036320
commit
0ebc610e49
10 changed files with 64 additions and 4 deletions
|
@ -2,6 +2,7 @@ class Commit
|
|||
|
||||
attr_accessor :commit
|
||||
attr_accessor :head
|
||||
attr_accessor :refs
|
||||
|
||||
delegate :message,
|
||||
:committed_date,
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -112,6 +112,16 @@ class Repository
|
|||
commits[0...n]
|
||||
end
|
||||
|
||||
def commits_with_refs(n = 20)
|
||||
commits = repo.refs.map { |ref| Commit.new(ref.commit, ref) }
|
||||
|
||||
commits.sort! do |x, y|
|
||||
y.committed_date <=> x.committed_date
|
||||
end[0..n]
|
||||
|
||||
commits
|
||||
end
|
||||
|
||||
def commits_since(date)
|
||||
commits = heads.map do |h|
|
||||
repo.log(h.name, nil, :since => date).each { |c| Commit.new(c, h) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue