summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-09-25 13:13:32 +0100
committerFilipa Lacerda <filipa@gitlab.com>2017-09-25 13:13:32 +0100
commit6a9258928ee39ade0e73d6104b899bd95350e83d (patch)
tree6f6cea18448820e68824d40c1e29960c67e038f2 /app/models
parent7b3e29c53b21225c5714b635aa0abde3dfcdfb03 (diff)
parent8b1a3d40e76093ff6ffd28a6e08280f4b29afc8e (diff)
downloadgitlab-ce-34371-cycle-analitcs-components-vue.tar.gz
Merge branch 'master' into 34371-cycle-analitcs-components-vue34371-cycle-analitcs-components-vue
* master: Removes cycle analytics service and store from global namespace Migrate Gitlab::Git::Repository#log to Gitaly Update tests to reflect `user_avatar_without_link` helper changes Add instructions for upgrading from CE to EE using GitLab Omnibus chart - docs Add `data-src` when image is to be lazy loaded, use `tag` helper instead of `image_tag` helper Remove unnecessary use of `gsub` Fixed few gitlab:check tasks that were failing with exception Update CHANGELOG.md for 10.0.1 Remove Grit settings from default settings Improve list of sorting options Remove navbar gradient spec fixes Fixed fly-out error if mousePos array is empty Refactor spec/policies/project_policy_spec.rb to minimize the diff with EE Make the "customizes the whitelist only once" spec less brittle Re-allow `name` attribute on user-provided anchor HTML simplify link_to call Fixes dashboard/projects empty state showing when viewing personal projects Add context tabs to dashboard/projects fix minor spelling mistakes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/issuable.rb24
-rw-r--r--app/models/concerns/sortable.rb15
-rw-r--r--app/models/issue.rb3
3 files changed, 23 insertions, 19 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 265f6e48540..fc30d008dea 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -143,16 +143,18 @@ module Issuable
end
def sort(method, excluded_labels: [])
- sorted = case method.to_s
- when 'milestone_due_asc' then order_milestone_due_asc
- when 'milestone_due_desc' then order_milestone_due_desc
- when 'downvotes_desc' then order_downvotes_desc
- when 'upvotes_desc' then order_upvotes_desc
- when 'label_priority' then order_labels_priority(excluded_labels: excluded_labels)
- when 'priority' then order_due_date_and_labels_priority(excluded_labels: excluded_labels)
- else
- order_by(method)
- end
+ sorted =
+ case method.to_s
+ when 'downvotes_desc' then order_downvotes_desc
+ when 'label_priority' then order_labels_priority(excluded_labels: excluded_labels)
+ when 'milestone' then order_milestone_due_asc
+ when 'milestone_due_asc' then order_milestone_due_asc
+ when 'milestone_due_desc' then order_milestone_due_desc
+ when 'popularity' then order_upvotes_desc
+ when 'priority' then order_due_date_and_labels_priority(excluded_labels: excluded_labels)
+ when 'upvotes_desc' then order_upvotes_desc
+ else order_by(method)
+ end
# Break ties with the ID column for pagination
sorted.order(id: :desc)
@@ -214,7 +216,7 @@ module Issuable
def grouping_columns(sort)
grouping_columns = [arel_table[:id]]
- if %w(milestone_due_desc milestone_due_asc).include?(sort)
+ if %w(milestone_due_desc milestone_due_asc milestone).include?(sort)
milestone_table = Milestone.arel_table
grouping_columns << milestone_table[:id]
grouping_columns << milestone_table[:due_date]
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb
index db3cd257584..cefa5c13c5f 100644
--- a/app/models/concerns/sortable.rb
+++ b/app/models/concerns/sortable.rb
@@ -19,14 +19,15 @@ module Sortable
module ClassMethods
def order_by(method)
case method.to_s
- when 'name_asc' then order_name_asc
- when 'name_desc' then order_name_desc
- when 'updated_asc' then order_updated_asc
- when 'updated_desc' then order_updated_desc
- when 'created_asc' then order_created_asc
+ when 'created_asc' then order_created_asc
+ when 'created_date' then order_created_desc
when 'created_desc' then order_created_desc
- when 'id_desc' then order_id_desc
- when 'id_asc' then order_id_asc
+ when 'id_asc' then order_id_asc
+ when 'id_desc' then order_id_desc
+ when 'name_asc' then order_name_asc
+ when 'name_desc' then order_name_desc
+ when 'updated_asc' then order_updated_asc
+ when 'updated_desc' then order_updated_desc
else
all
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 92a454300af..155c5d972b7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -116,7 +116,8 @@ class Issue < ActiveRecord::Base
def self.sort(method, excluded_labels: [])
case method.to_s
- when 'due_date_asc' then order_due_date_asc
+ when 'due_date' then order_due_date_asc
+ when 'due_date_asc' then order_due_date_asc
when 'due_date_desc' then order_due_date_desc
else
super