From 5b698082323e019e47b5c739cdec0300b521340b Mon Sep 17 00:00:00 2001
From: Sean McGivern <sean@gitlab.com>
Date: Wed, 5 Apr 2017 11:24:15 +0100
Subject: [PATCH] Rename user cohorts -> cohorts

---
 app/assets/javascripts/dispatcher.js                     | 2 +-
 app/controllers/admin/cohorts_controller.rb              | 9 +++++++++
 app/controllers/admin/user_cohorts_controller.rb         | 9 ---------
 .../{user_cohorts_service.rb => cohorts_service.rb}      | 2 +-
 .../{user_cohorts => cohorts}/_cohorts_table.html.haml   | 0
 .../{user_cohorts => cohorts}/_usage_ping.html.haml      | 0
 .../admin/{user_cohorts => cohorts}/index.html.haml      | 0
 app/views/admin/dashboard/_head.html.haml                | 6 +++---
 config/routes/admin.rb                                   | 2 +-
 ...r_cohorts_service_spec.rb => cohorts_service_spec.rb} | 2 +-
 10 files changed, 16 insertions(+), 16 deletions(-)
 create mode 100644 app/controllers/admin/cohorts_controller.rb
 delete mode 100644 app/controllers/admin/user_cohorts_controller.rb
 rename app/services/{user_cohorts_service.rb => cohorts_service.rb} (99%)
 rename app/views/admin/{user_cohorts => cohorts}/_cohorts_table.html.haml (100%)
 rename app/views/admin/{user_cohorts => cohorts}/_usage_ping.html.haml (100%)
 rename app/views/admin/{user_cohorts => cohorts}/index.html.haml (100%)
 rename spec/services/{user_cohorts_service_spec.rb => cohorts_service_spec.rb} (98%)

diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index 6c94975d851..a0afffb6635 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -366,7 +366,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
           new Admin();
           switch (path[1]) {
             case 'application_settings':
-            case 'user_cohorts':
+            case 'cohorts':
               new gl.ApplicationSettings();
               break;
             case 'groups':
diff --git a/app/controllers/admin/cohorts_controller.rb b/app/controllers/admin/cohorts_controller.rb
new file mode 100644
index 00000000000..947afe3a028
--- /dev/null
+++ b/app/controllers/admin/cohorts_controller.rb
@@ -0,0 +1,9 @@
+class Admin::CohortsController < Admin::ApplicationController
+  def index
+    if ApplicationSetting.current.usage_ping_enabled
+      @cohorts = Rails.cache.fetch('cohorts', expires_in: 1.day) do
+        CohortsService.new.execute
+      end
+    end
+  end
+end
diff --git a/app/controllers/admin/user_cohorts_controller.rb b/app/controllers/admin/user_cohorts_controller.rb
deleted file mode 100644
index 1d9e3547807..00000000000
--- a/app/controllers/admin/user_cohorts_controller.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Admin::UserCohortsController < Admin::ApplicationController
-  def index
-    if ApplicationSetting.current.usage_ping_enabled
-      @cohorts = Rails.cache.fetch('user_cohorts', expires_in: 1.day) do
-        UserCohortsService.new.execute
-      end
-    end
-  end
-end
diff --git a/app/services/user_cohorts_service.rb b/app/services/cohorts_service.rb
similarity index 99%
rename from app/services/user_cohorts_service.rb
rename to app/services/cohorts_service.rb
index c7909bb9e07..e7f8a50605f 100644
--- a/app/services/user_cohorts_service.rb
+++ b/app/services/cohorts_service.rb
@@ -1,4 +1,4 @@
-class UserCohortsService
+class CohortsService
   MONTHS_INCLUDED = 12
 
   # Get a hash that looks like:
diff --git a/app/views/admin/user_cohorts/_cohorts_table.html.haml b/app/views/admin/cohorts/_cohorts_table.html.haml
similarity index 100%
rename from app/views/admin/user_cohorts/_cohorts_table.html.haml
rename to app/views/admin/cohorts/_cohorts_table.html.haml
diff --git a/app/views/admin/user_cohorts/_usage_ping.html.haml b/app/views/admin/cohorts/_usage_ping.html.haml
similarity index 100%
rename from app/views/admin/user_cohorts/_usage_ping.html.haml
rename to app/views/admin/cohorts/_usage_ping.html.haml
diff --git a/app/views/admin/user_cohorts/index.html.haml b/app/views/admin/cohorts/index.html.haml
similarity index 100%
rename from app/views/admin/user_cohorts/index.html.haml
rename to app/views/admin/cohorts/index.html.haml
diff --git a/app/views/admin/dashboard/_head.html.haml b/app/views/admin/dashboard/_head.html.haml
index 0c2e5efc052..163bd5662b0 100644
--- a/app/views/admin/dashboard/_head.html.haml
+++ b/app/views/admin/dashboard/_head.html.haml
@@ -27,7 +27,7 @@
           = link_to admin_runners_path, title: 'Runners' do
             %span
               Runners
-        = nav_link path: 'user_cohorts#index' do
-          = link_to admin_user_cohorts_path, title: 'User cohorts' do
+        = nav_link path: 'cohorts#index' do
+          = link_to admin_cohorts_path, title: 'Cohorts' do
             %span
-              User cohorts
+              Cohorts
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index 5b44d449b2b..52ba10604d4 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -106,7 +106,7 @@ namespace :admin do
     end
   end
 
-  resources :user_cohorts, only: :index
+  resources :cohorts, only: :index
 
   resources :builds, only: :index do
     collection do
diff --git a/spec/services/user_cohorts_service_spec.rb b/spec/services/cohorts_service_spec.rb
similarity index 98%
rename from spec/services/user_cohorts_service_spec.rb
rename to spec/services/cohorts_service_spec.rb
index 4db8d577d79..878e9fcea05 100644
--- a/spec/services/user_cohorts_service_spec.rb
+++ b/spec/services/cohorts_service_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-describe UserCohortsService do
+describe CohortsService do
   describe '#execute' do
     def month_start(months_ago)
       months_ago.months.ago.beginning_of_month.to_date
-- 
2.30.9