summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-05 20:29:41 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-05 20:29:41 -0800
commit8952fc015fae476a20051c01cf4217d82d30c83d (patch)
tree07f05c55ff385ce176e148116a04f7abb3a9558a /app
parentc5be267e40c0ba05c2a7de6a71d154f1b5161160 (diff)
downloadgitlab-ce-8952fc015fae476a20051c01cf4217d82d30c83d.tar.gz
Apply default scope to labels and remove one for notes
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/commits_controller.rb2
-rw-r--r--app/controllers/projects/labels_controller.rb2
-rw-r--r--app/controllers/projects/merge_requests_controller.rb2
-rw-r--r--app/finders/notes_finder.rb3
-rw-r--r--app/models/label.rb4
-rw-r--r--app/models/note.rb1
-rw-r--r--app/views/shared/_issuable_filter.html.haml2
7 files changed, 7 insertions, 9 deletions
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb
index 0a85c36a758..b133afe44b5 100644
--- a/app/controllers/projects/commits_controller.rb
+++ b/app/controllers/projects/commits_controller.rb
@@ -13,7 +13,7 @@ class Projects::CommitsController < Projects::ApplicationController
@commits = @repo.commits(@ref, @path, @limit, @offset)
@note_counts = Note.where(commit_id: @commits.map(&:id)).
- group(:commit_id).count
+ group(:commit_id).count
respond_to do |format|
format.html
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 6c7bde9c5d5..b61fef3b627 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -7,7 +7,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html
def index
- @labels = @project.labels.order_by_name.page(params[:page]).per(20)
+ @labels = @project.labels.page(params[:page]).per(20)
end
def new
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 912f9eb5b6b..01be318ede2 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -23,7 +23,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def show
@note_counts = Note.where(commit_id: @merge_request.commits.map(&:id)).
- group(:commit_id).count
+ group(:commit_id).count
respond_to do |format|
format.html
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb
index 6fe15b41060..e2bd0a2560e 100644
--- a/app/finders/notes_finder.rb
+++ b/app/finders/notes_finder.rb
@@ -22,6 +22,7 @@ class NotesFinder
end
# Use overlapping intervals to avoid worrying about race conditions
- notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP)
+ notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP).
+ order(created_at: :asc, id: :asc)
end
end
diff --git a/app/models/label.rb b/app/models/label.rb
index c8f6a7cd48c..9d7099c5652 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -11,8 +11,6 @@
#
class Label < ActiveRecord::Base
- include Sortable
-
DEFAULT_COLOR = '#428BCA'
belongs_to :project
@@ -30,7 +28,7 @@ class Label < ActiveRecord::Base
format: { with: /\A[^&\?,&]+\z/ },
uniqueness: { scope: :project_id }
- scope :order_by_name, -> { reorder("labels.title ASC") }
+ default_scope { order(title: :asc) }
alias_attribute :name, :title
diff --git a/app/models/note.rb b/app/models/note.rb
index a3f2980cebd..0b988cc3e0f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -23,7 +23,6 @@ require 'file_size_validator'
class Note < ActiveRecord::Base
include Mentionable
- default_scope { order(created_at: :asc, id: :asc) }
default_value_for :system, false
attr_mentionable :note
diff --git a/app/views/shared/_issuable_filter.html.haml b/app/views/shared/_issuable_filter.html.haml
index 4f683258fac..cd97481bb6c 100644
--- a/app/views/shared/_issuable_filter.html.haml
+++ b/app/views/shared/_issuable_filter.html.haml
@@ -98,7 +98,7 @@
= link_to page_filter_path(label_name: nil) do
Any
- if @project.labels.any?
- - @project.labels.order_by_name.each do |label|
+ - @project.labels.each do |label|
%li
= link_to page_filter_path(label_name: label.name) do
= render_colored_label(label)