summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 33dd85e2f32..93637822a74 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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")