Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-02-16 14:58:12 +0300
committerRémy Coutable <remy@rymai.me>2016-02-16 14:58:12 +0300
commitd28fa2ce233e057dc47de17bb6c1f2dff141059a (patch)
tree6942bb6cde0b9adda7423f0705b3e38516602b3d
parent54613b6af56008588a3cc8a9e9f2ee642ca59a36 (diff)
Display "iid of max_iid" in Issuables' sidebar
-rw-r--r--app/helpers/issuables_helper.rb12
-rw-r--r--app/models/concerns/issuable.rb10
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml2
3 files changed, 5 insertions, 19 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index ccbd93967a2..91a3aa371ef 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -8,20 +8,16 @@ module IssuablesHelper
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end
- def issuable_index(issuable)
- base_issuable_scope(issuable).where('id < ?', issuable.id).size + 1
- end
-
def issuables_count(issuable)
- base_issuable_scope(issuable).size
+ base_issuable_scope(issuable).maximum(:iid)
end
def next_issuable_for(issuable)
- base_issuable_scope(issuable).where('id > ?', issuable.id).last
+ base_issuable_scope(issuable).where('iid > ?', issuable.iid).last
end
def prev_issuable_for(issuable)
- base_issuable_scope(issuable).where('id < ?', issuable.id).first
+ base_issuable_scope(issuable).where('iid < ?', issuable.iid).first
end
private
@@ -31,7 +27,7 @@ module IssuablesHelper
end
def base_issuable_scope(issuable)
- issuable.project.send(issuable.to_scope_name).send(issuable_state_scope(issuable))
+ issuable.project.send(issuable.class.table_name).send(issuable_state_scope(issuable))
end
def issuable_state_scope(issuable)
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index e08687135d6..cf6aa592e2a 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -168,16 +168,6 @@ module Issuable
self.class.to_s.underscore
end
- # Convert this Issuable class name to a format usable for scoping
- #
- # Examples:
- #
- # issuable.class # => MergeRequest
- # issuable.to_scope_name # => "merge_requests"
- def to_scope_name
- self.class.to_s.tableize
- end
-
# Returns a Hash of attributes to be used for Twitter card metadata
def card_attributes
{
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index cb5378964bc..e1aecdd9436 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -2,7 +2,7 @@
.issuable-sidebar
.block
%span.issuable-count.pull-left
- = issuable_index(issuable)
+ = issuable.iid
of
= issuables_count(issuable)
%span.pull-right