Commit 39a1ed5f authored by Changzheng Liu's avatar Changzheng Liu

Only delete data from Elasticsearch 30 days after subscription expires

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72923
EE: true
parent 27696431
......@@ -31,9 +31,9 @@ class GitlabSubscription < ApplicationRecord
scope :preload_for_refresh_seat, -> { preload([{ namespace: :route }, :hosted_plan]) }
DAYS_AFTER_EXPIRATION_BEFORE_REMOVING_FROM_INDEX = 7
DAYS_AFTER_EXPIRATION_BEFORE_REMOVING_FROM_INDEX = 30
# We set a 7 days as the threshold for expiration before removing them from
# We set a threshold for expiration before removing them from
# the index
def self.yield_long_expired_indexed_namespaces(&blk)
# Since the gitlab_subscriptions table will keep growing in size and the
......
......@@ -476,8 +476,8 @@ RSpec.describe GitlabSubscription do
let_it_be(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) }
let_it_be(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) }
let_it_be(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) }
let_it_be(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 8) }
let_it_be(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 10) }
let_it_be(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 31) }
let_it_be(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 40) }
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
......
......@@ -8,8 +8,8 @@ RSpec.describe ElasticRemoveExpiredNamespaceSubscriptionsFromIndexCronWorker do
let(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) }
let(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) }
let(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) }
let(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 8) }
let(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 10) }
let(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 31) }
let(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 35) }
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
......
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