Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-23 18:00:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-23 18:00:18 +0300
commit6ce82deda34e8af9d07cf7dfff0057f33b9e6187 (patch)
treee88b7ca57376e83556c7a651d61dbe8ba09440b5 /lib
parent3d62fe7ad9b32c2e68d253d0b2bd178215c65fa5 (diff)
Add latest changes from gitlab-org/gitlab@13-7-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/reset_shared_runners_for_transferred_projects.rb30
-rw-r--r--lib/gitlab/usage_data_counters/hll_redis_counter.rb10
2 files changed, 34 insertions, 6 deletions
diff --git a/lib/gitlab/background_migration/reset_shared_runners_for_transferred_projects.rb b/lib/gitlab/background_migration/reset_shared_runners_for_transferred_projects.rb
new file mode 100644
index 00000000000..0053cafb4ac
--- /dev/null
+++ b/lib/gitlab/background_migration/reset_shared_runners_for_transferred_projects.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Resets inconsistent state of shared_runners_enabled for projects that have been transferred
+ class ResetSharedRunnersForTransferredProjects
+ # Model specifically used for migration.
+ class Namespace < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'namespaces'
+ end
+
+ # Model specifically used for migration.
+ class Project < ActiveRecord::Base
+ self.table_name = 'projects'
+ end
+
+ def perform(start_id, stop_id)
+ Project.reset_column_information
+
+ Namespace.where(id: start_id..stop_id).each_batch(of: 1_000) do |relation|
+ ids = relation.where(shared_runners_enabled: false, allow_descendants_override_disabled_shared_runners: false).select(:id)
+
+ Project.where(namespace_id: ids).update_all(shared_runners_enabled: false)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/usage_data_counters/hll_redis_counter.rb b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
index 573ad1dce35..b61720c7638 100644
--- a/lib/gitlab/usage_data_counters/hll_redis_counter.rb
+++ b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
@@ -336,12 +336,10 @@ module Gitlab
end
def weekly_redis_keys(events:, start_date:, end_date:, context: '')
- weeks = end_date.to_date.cweek - start_date.to_date.cweek
- weeks = 1 if weeks == 0
-
- (0..(weeks - 1)).map do |week_increment|
- events.map { |event| redis_key(event, start_date + week_increment * 7.days, context) }
- end.flatten
+ end_date = end_date.end_of_week - 1.week
+ (start_date.to_date..end_date.to_date).map do |date|
+ events.map { |event| redis_key(event, date, context) }
+ end.flatten.uniq
end
end
end