summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-10 06:09:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-10 06:09:14 +0000
commite0df70a614e6381d1ccb9547f23c797063ba6dfc (patch)
tree07090fb55549010133375938d8aa9352443f8d88 /lib
parent5d756f9966c2f91b96cef7e552693e5bd1f1fb21 (diff)
downloadgitlab-ce-e0df70a614e6381d1ccb9547f23c797063ba6dfc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/generators/gitlab/usage_metric_definition_generator.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/generators/gitlab/usage_metric_definition_generator.rb b/lib/generators/gitlab/usage_metric_definition_generator.rb
index 6ba6b8b1f5b..7a01050ed0c 100644
--- a/lib/generators/gitlab/usage_metric_definition_generator.rb
+++ b/lib/generators/gitlab/usage_metric_definition_generator.rb
@@ -74,6 +74,7 @@ module Gitlab
def validate!
raise "--dir option is required" unless input_dir.present?
raise "Invalid dir #{input_dir}, allowed options are #{VALID_INPUT_DIRS.join(', ')}" unless directory.present?
+ raise "Metric definition with key path '#{key_path}' already exists" if metric_definition_exists?
end
def ee?
@@ -88,11 +89,23 @@ module Gitlab
#
# 20210201124931_g_project_management_issue_title_changed_weekly.yml
def file_name
- "#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{key_path.split('.').last}"
+ "#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{metric_name}"
end
def directory
@directory ||= TIME_FRAME_DIRS.find { |d| d.match?(input_dir) }
end
+
+ def metric_name
+ key_path.split('.').last
+ end
+
+ def metric_definitions
+ @definitions ||= Gitlab::Usage::MetricDefinition.definitions
+ end
+
+ def metric_definition_exists?
+ metric_definitions[key_path].present?
+ end
end
end