diff options
author | Marius Mathiesen <marius@shortcut.no> | 2009-07-13 14:03:10 +0200 |
---|---|---|
committer | Marius Mathiesen <marius@shortcut.no> | 2009-07-13 15:15:42 +0200 |
commit | 0ec2f19f20a0bda061ed233779543ce1d1336f0c (patch) | |
tree | e6fb8a5022db2db8e1953dc37944612823afeec4 /app/models | |
parent | c8095706a0948361346e83e8de6974bf3a29674a (diff) | |
download | gitorious-mainline-outdated-0ec2f19f20a0bda061ed233779543ce1d1336f0c.zip gitorious-mainline-outdated-0ec2f19f20a0bda061ed233779543ce1d1336f0c.tar.gz gitorious-mainline-outdated-0ec2f19f20a0bda061ed233779543ce1d1336f0c.tar.bz2 |
Supplying a list of status tags per repository when listing merge requests:
- add a list of unique status_tags
- MergeRequest.from_filter uses a named scope by filter when given a non-defined string
MergeRequest.from_filter now uses either a predefined name scope, the by_status named scope
or open (when given nil)
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/merge_request.rb | 7 | ||||
-rw-r--r-- | app/models/repository.rb | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 374fd50..bef3a0b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -80,10 +80,13 @@ class MergeRequest < ActiveRecord::Base end end - named_scope :open, :conditions => ['LCASE(status_tag) in (?)', ['open','verifying']] + named_scope :open, :conditions => ['LCASE(status_tag) in (?) OR status_tag IS NULL', ['open','verifying']] named_scope :closed, :conditions => ["LCASE(status_tag) in (?)", ['merged','rejected']] named_scope :merged, :conditions => ["LCASE(status_tag) = ?", 'merged'] named_scope :rejected, :conditions => ["LCASE(status_tag) = ?", 'rejected'] + named_scope :by_status, lambda {|state| + {:conditions => ["LCASE(status_tag) = ?", state ] } + } def reopen_with_user(a_user) @@ -119,6 +122,8 @@ class MergeRequest < ActiveRecord::Base merged when "rejected" rejected + when String + by_status(filter_name) else open end diff --git a/app/models/repository.rb b/app/models/repository.rb index d41446d..5371991 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -572,6 +572,11 @@ class Repository < ActiveRecord::Base def has_tracking_repository? !tracking_repository.nil? end + + def merge_request_status_tags + result = MergeRequest.find_by_sql(["SELECT status_tag FROM merge_requests WHERE target_repository_id = ? GROUP BY status_tag", self.id]).collect(&:status_tag) + result.compact + end protected def sharded_hashed_path(h) |