summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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