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-03-18 23:49:56 +0300
committerRémy Coutable <remy@rymai.me>2016-03-18 23:49:56 +0300
commit733ae58798f6736af156e94b6906ac9c0b76fa3d (patch)
treec316a0a7b67a1f46d9e3c59cf8b699989dfebba7 /app/controllers/dashboard_controller.rb
parentc790107854658a37d97b9a1c9066338eb12b06bf (diff)
Dedupe labels in labels selector in Dashboard pages
Also moved useless helper methods and directly to the DashboardController.
Diffstat (limited to 'app/controllers/dashboard_controller.rb')
-rw-r--r--app/controllers/dashboard_controller.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 36986d9a18d..b538c7d1608 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -21,17 +21,24 @@ class DashboardController < Dashboard::ApplicationController
end
def labels
+ labels = Label.where(project_id: @projects).select(:title, :color).uniq(:title)
+
respond_to do |format|
format.json do
- render json: view_context.projects_labels_options
+ render json: labels
end
end
end
def milestones
+ milestones = Milestone.where(project_id: @projects).active
+ epoch = DateTime.parse('1970-01-01')
+ grouped_milestones = GlobalMilestone.build_collection(milestones)
+ grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
+
respond_to do |format|
format.json do
- render json: view_context.projects_milestones_options
+ render json: grouped_milestones
end
end
end