From 7554378e710e49abedcad46e288af00f92401c40 Mon Sep 17 00:00:00 2001 From: Matt Hinz Date: Fri, 17 Nov 2023 13:55:03 -0800 Subject: [PATCH] Remove GPO verification rake task This was just glue to support running the job, and is no longer needed. [skip changelog] --- lib/tasks/backfill_gpo_expiration.rake | 69 -------------------------- 1 file changed, 69 deletions(-) delete mode 100644 lib/tasks/backfill_gpo_expiration.rake diff --git a/lib/tasks/backfill_gpo_expiration.rake b/lib/tasks/backfill_gpo_expiration.rake deleted file mode 100644 index 59d1db6f9d0..00000000000 --- a/lib/tasks/backfill_gpo_expiration.rake +++ /dev/null @@ -1,69 +0,0 @@ -namespace :profiles do - desc 'Backfill the gpo_verification_expired_at value' - - ## - # Usage: - # - # Print pending updates - # bundle exec rake profiles:backfill_gpo_expiration > profiles.csv - # - # Commit updates - # bundle exec rake profiles:backfill_gpo_expiration UPDATE_PROFILES=true > profiles.csv - # - task backfill_gpo_expiration: :environment do |_task, _args| - min_profile_age = (ENV['MIN_PROFILE_AGE_IN_DAYS'].to_i || 100).days - update_profiles = ENV['UPDATE_PROFILES'] == 'true' - statement_timeout = ENV['STATEMENT_TIMEOUT_IN_SECONDS'].to_i.seconds || 10.minutes - - count = 0 - earliest = nil - latest = nil - - on_profile_expired = ->(profile:, gpo_verification_pending_at:) do - count += 1 - - earliest = [earliest, gpo_verification_pending_at].compact.min - latest = [latest, gpo_verification_pending_at].compact.max - - puts "#{profile.id},#{gpo_verification_pending_at.iso8601}" - - if count % 100 == 0 - verb = update_profiles ? 'Expired' : 'Found' - warn "#{verb} #{count} profiles (earliest: #{earliest}, latest: #{latest})" - end - end - - job = GpoExpirationJob.new(on_profile_expired: on_profile_expired) - - job.perform( - now: Time.zone.now, - min_profile_age: min_profile_age, - dry_run: !update_profiles, - statement_timeout: statement_timeout, - ) - end - - ## - # Usage: - # - # Rollback the above: - # - # bundle exec rake profiles:rollback_backfill_gpo_expiration < profiles.csv - # - task rollback_backfill_gpo_expiration: :environment do |_task, _args| - profile_data = STDIN.read.split("\n").map do |profile_row| - profile_row.split(',') - end - - warn "Updating #{profile_data.count} records" - - profile_data.each do |profile_datum| - profile_id, gpo_verification_pending_at = profile_datum - Profile.where(id: profile_id).update!( - gpo_verification_pending_at: Time.zone.parse(gpo_verification_pending_at), - gpo_verification_expired_at: nil, - ) - warn profile_id - end - end -end