Commit 3fd9cc8a authored by Adam Hegyi's avatar Adam Hegyi

Merge branch...

Merge branch '251048-modify-time-period-for-batch-counting-performance-of-the-last-portion-of-the-loops' into 'master'

Improve batch counting performance for last 28 days

See merge request gitlab-org/gitlab!42972
parents 12f25f34 4689069a
---
title: Modify time_period for last 28 days to improve batch counting performance
merge_request: 42972
author:
type: performance
......@@ -478,9 +478,10 @@ RSpec.describe Gitlab::UsageData do
end
describe 'usage_activity_by_stage_secure' do
let_it_be(:user) { create(:user, group_view: :security_dashboard) }
let_it_be(:user2) { create(:user, group_view: :security_dashboard) }
let_it_be(:user3) { create(:user, group_view: :security_dashboard) }
let_it_be(:days_ago_within_monthly_time_period) { 3.days.ago }
let_it_be(:user) { create(:user, group_view: :security_dashboard, created_at: days_ago_within_monthly_time_period) }
let_it_be(:user2) { create(:user, group_view: :security_dashboard, created_at: days_ago_within_monthly_time_period) }
let_it_be(:user3) { create(:user, group_view: :security_dashboard, created_at: days_ago_within_monthly_time_period) }
before do
for_defined_days_back do
......
......@@ -473,7 +473,7 @@ module Gitlab
end
def last_28_days_time_period(column: :created_at)
{ column => 28.days.ago..Time.current }
{ column => 30.days.ago..2.days.ago }
end
# Source: https://gitlab.com/gitlab-data/analytics/blob/master/transform/snowflake-dbt/data/ping_metrics_to_stage_mapping_data.csv
......
......@@ -97,9 +97,9 @@ FactoryBot.define do
create(:grafana_integration, project: projects[1], enabled: true)
create(:grafana_integration, project: projects[2], enabled: false)
create(:package, project: projects[0])
create(:package, project: projects[0])
create(:package, project: projects[1])
create(:package, project: projects[0], created_at: 3.days.ago)
create(:package, project: projects[0], created_at: 3.days.ago)
create(:package, project: projects[1], created_at: 3.days.ago)
create(:package, created_at: 2.months.ago, project: projects[1])
# User Preferences
......@@ -109,7 +109,7 @@ FactoryBot.define do
# Create fresh & a month (28-days SMAU) old data
env = create(:environment, project: projects[3])
[2, 29].each do |n|
[3, 31].each do |n|
deployment_options = { created_at: n.days.ago, project: env.project, environment: env }
create(:deployment, :failed, deployment_options)
create(:deployment, :success, deployment_options)
......
......@@ -1020,7 +1020,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
def for_defined_days_back(days: [29, 2])
def for_defined_days_back(days: [31, 3])
days.each do |n|
Timecop.travel(n.days.ago) do
yield
......
......@@ -229,7 +229,7 @@ module UsageDataHelpers
receive_matchers.each { |m| expect(prometheus_client).to m }
end
def for_defined_days_back(days: [29, 2])
def for_defined_days_back(days: [31, 3])
days.each do |n|
Timecop.travel(n.days.ago) do
yield
......
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