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:
Diffstat (limited to 'lib/milestone_array.rb')
-rw-r--r--lib/milestone_array.rb42
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/milestone_array.rb b/lib/milestone_array.rb
deleted file mode 100644
index 461e73e9670..00000000000
--- a/lib/milestone_array.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-
-module MilestoneArray
- class << self
- def sort(array, sort_method)
- case sort_method
- when 'due_date_asc'
- sort_asc_nulls_last(array, 'due_date')
- when 'due_date_desc'
- sort_desc_nulls_last(array, 'due_date')
- when 'start_date_asc'
- sort_asc_nulls_last(array, 'start_date')
- when 'start_date_desc'
- sort_desc_nulls_last(array, 'start_date')
- when 'name_asc'
- sort_asc(array, 'title')
- when 'name_desc'
- sort_asc(array, 'title').reverse
- else
- array
- end
- end
-
- private
-
- def sort_asc_nulls_last(array, attribute)
- attribute = attribute.to_sym
-
- array.select(&attribute).sort_by(&attribute) + array.reject(&attribute)
- end
-
- def sort_desc_nulls_last(array, attribute)
- attribute = attribute.to_sym
-
- array.select(&attribute).sort_by(&attribute).reverse + array.reject(&attribute)
- end
-
- def sort_asc(array, attribute)
- array.sort_by(&attribute.to_sym)
- end
- end
-end