Commit 35fcedd3 authored by Ryan Cobb's avatar Ryan Cobb

Rename Gitlab::Importers module

In order to avoid confusion between Gitlab::Importers module and other
like named modules, this renamed it to Gitlab::DatabaseImporters.
parent d3d0ebe2
# frozen_string_literal: true
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
# frozen_string_literal: true
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
......@@ -6,7 +6,7 @@ class ImportCommonMetrics < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -4,7 +4,7 @@ class ImportCommonMetricsNginxVts < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -6,7 +6,7 @@ class ImportCommonMetricsKnative < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -9,7 +9,7 @@ class PrometheusKnative05Fix < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -36,7 +36,7 @@ class ImportCommonMetrics < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
::Gitlab::Importers::CommonMetrics::Importer.new.execute
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
......
......@@ -2,7 +2,7 @@
module EE
module Gitlab
module Importers
module DatabaseImporters
module CommonMetrics
module PrometheusMetricEnums
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module Gitlab
module Importers
module DatabaseImporters
module CommonMetrics
end
end
end
Gitlab::Importers::CommonMetrics.prepend(EE::Gitlab::Importers::CommonMetrics)
Gitlab::DatabaseImporters::CommonMetrics.prepend(EE::Gitlab::DatabaseImporters::CommonMetrics)
# frozen_string_literal: true
module Gitlab
module Importers
module DatabaseImporters
module CommonMetrics
class Importer
MissingQueryId = Class.new(StandardError)
......@@ -58,14 +58,12 @@ module Gitlab
yield(metric_details['id'], attributes)
end
# rubocop: disable CodeReuse/ActiveRecord
def find_or_build_metric!(id)
raise MissingQueryId unless id
CommonMetrics::PrometheusMetric.common.find_by(identifier: id) ||
CommonMetrics::PrometheusMetric.new(common: true, identifier: id)
end
# rubocop: enable CodeReuse/ActiveRecord
def find_group_title_key(title)
CommonMetrics::PrometheusMetricEnums.groups[find_group_title(title)]
......
# frozen_string_literal: true
module Gitlab
module Importers
module DatabaseImporters
module CommonMetrics
class PrometheusMetric < ApplicationRecord
enum group: PrometheusMetricEnums.groups
......
# frozen_string_literal: true
module Gitlab
module Importers
module DatabaseImporters
module CommonMetrics
module PrometheusMetricEnums
def self.groups
......@@ -39,4 +39,4 @@ module Gitlab
end
end
::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.prepend EE::Gitlab::Importers::CommonMetrics::PrometheusMetricEnums
::Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetricEnums.prepend EE::Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetricEnums
......@@ -2,7 +2,7 @@
require 'rails_helper'
describe Gitlab::Importers::CommonMetrics::Importer do
describe Gitlab::DatabaseImporters::CommonMetrics::Importer do
subject { described_class.new }
context "does import common_metrics.yml" do
......@@ -87,7 +87,7 @@ describe Gitlab::Importers::CommonMetrics::Importer do
let(:query_identifier) { }
it 'raises exception' do
expect { subject.execute }.to raise_error(Gitlab::Importers::CommonMetrics::Importer::MissingQueryId)
expect { subject.execute }.to raise_error(Gitlab::DatabaseImporters::CommonMetrics::Importer::MissingQueryId)
end
end
......
......@@ -2,7 +2,7 @@
require 'rails_helper'
describe Gitlab::Importers::CommonMetrics::PrometheusMetric do
describe Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetric do
let(:existing_group_titles) do
::PrometheusMetricEnums.group_details.each_with_object({}) do |(key, value), memo|
memo[key] = value[:group_title]
......@@ -14,6 +14,6 @@ describe Gitlab::Importers::CommonMetrics::PrometheusMetric do
end
it '.group_titles equals ::PrometheusMetric' do
expect(Gitlab::Importers::CommonMetrics::PrometheusMetricEnums.group_titles).to eq(existing_group_titles)
expect(Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetricEnums.group_titles).to eq(existing_group_titles)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment