summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:53:00 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:53:00 +0100
commitbda7fe38d0b0e39a408c4eb44374a330c24c3a49 (patch)
tree232212b8827c5be94da672287e3209c8e8f9f18a /app/models
parentd28176b132bdc74055f31e2d62665d5d74ebacb4 (diff)
parentd8e697ac68d758d4f451594047056c459f546bf7 (diff)
downloadgitlab-ce-bda7fe38d0b0e39a408c4eb44374a330c24c3a49.tar.gz
Merge branch 'master' into discussions
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb15
-rw-r--r--app/models/repository.rb6
-rw-r--r--app/models/wiki.rb2
3 files changed, 19 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 32b951349a9..ac32352837a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -28,7 +28,7 @@ class Project < ActiveRecord::Base
attr_accessible :name, :path, :description, :default_branch, :issues_enabled,
:wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin]
- attr_accessible :namespace_id, :creator_id, as: :admin
+ attr_accessible :namespace_id, :creator_id, :public, as: :admin
attr_accessor :error_code
@@ -81,8 +81,21 @@ class Project < ActiveRecord::Base
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
+ scope :public, where(public: true)
class << self
+ def abandoned
+ project_ids = Event.select('max(created_at) as latest_date, project_id').
+ group('project_id').
+ having('latest_date < ?', 6.months.ago).map(&:project_id)
+
+ where(id: project_ids)
+ end
+
+ def with_push
+ includes(:events).where('events.action = ?', Event::Pushed)
+ end
+
def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index cf8ba4530a1..6bfdf2255f2 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -151,12 +151,12 @@ class Repository
return nil unless commit
# Build file path
- file_name = self.path + "-" + commit.id.to_s + ".tar.gz"
- storage_path = Rails.root.join("tmp", "repositories", self.path_with_namespace)
+ file_name = self.path_with_namespace + "-" + commit.id.to_s + ".tar.gz"
+ storage_path = Rails.root.join("tmp", "repositories")
file_path = File.join(storage_path, file_name)
# Put files into a directory before archiving
- prefix = self.path + "/"
+ prefix = self.path_with_namespace + "/"
# Create file if not exists
unless File.exists?(file_path)
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index 4f113957f99..7f488ca7625 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -25,6 +25,8 @@ class Wiki < ActiveRecord::Base
before_update :set_slug
+ scope :ordered, order("created_at DESC")
+
def to_param
slug
end