Commit 160cd80d authored by Mikolaj Wawrzyniak's avatar Mikolaj Wawrzyniak

Remove time frame constraint from name suggestion

Time frame attribute is captured within other attributes and
shouldn't be repeated inside name
parent cd09e9a6
...@@ -48,6 +48,10 @@ module Gitlab ...@@ -48,6 +48,10 @@ module Gitlab
end end
def name_suggestion(relation:, column: nil, prefix: nil, distinct: nil) def name_suggestion(relation:, column: nil, prefix: nil, distinct: nil)
# rubocop: disable CodeReuse/ActiveRecord
relation = relation.unscope(where: :created_at)
# rubocop: enable CodeReuse/ActiveRecord
parts = [prefix] parts = [prefix]
arel_column = arelize_column(relation, column) arel_column = arelize_column(relation, column)
......
...@@ -60,6 +60,15 @@ RSpec.describe Gitlab::Usage::Metrics::NamesSuggestions::Generator do ...@@ -60,6 +60,15 @@ RSpec.describe Gitlab::Usage::Metrics::NamesSuggestions::Generator do
end end
end end
context 'strips off time period constraint' do
it_behaves_like 'name suggestion' do
# corresponding metric is collected with distinct_count(::Clusters::Cluster.aws_installed.enabled.where(time_period), :user_id)
let(:key_path) { 'usage_activity_by_stage_monthly.configure.clusters_platforms_eks' }
let(:constraints) { /<adjective describing\: '\(clusters.provider_type = \d+ AND \("cluster_providers_aws"\."status" IN \(\d+\)\) AND clusters\.enabled = TRUE\)'>/ }
let(:name_suggestion) { /count_distinct_user_id_from_#{constraints}_clusters_<with>_#{constraints}_cluster_providers_aws/ }
end
end
context 'for sum metrics' do context 'for sum metrics' do
it_behaves_like 'name suggestion' do it_behaves_like 'name suggestion' do
# corresponding metric is collected with sum(JiraImportState.finished, :imported_issues_count) # corresponding metric is collected with sum(JiraImportState.finished, :imported_issues_count)
......
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