Class: OnlineMigrations::DataMigrations::DeleteSpuriousContactPanelOpenedEvents

Inherits:
OnlineMigrations::DataMigration
  • Object
show all
Defined in:
lib/online_migrations/data_migrations/delete_spurious_contact_panel_opened_events.rb

Overview

Deletes the spurious $contact_panel_opened visit events. Before the navbar
contact-panel lazy-load fix (#995), the panel's Turbo Frame eager-loaded via
src=… loading="lazy", so NavbarContactController#show — which records
$contact_panel_opened — fired on page render instead of when a user
actually opened the panel. Every such row is page-view noise (a real open
never re-fetched the already-loaded frame, so genuine opens were never
captured pre-fix). The fix makes the frame load only on open, so rows
recorded after it deploys are real and must be kept.

online_migrations bounds the work to the primary-key range present when the
migration starts, so genuine opens recorded afterwards (once the fix is
live) are never touched.

DEPLOY ORDER: ship the #995 fix first (ideally in the same release), then
enqueue this — so the noise/real boundary lines up with the fix going live.

Monitor:
OnlineMigrations::BackgroundDataMigrations::Migration
.find_by(migration_name: 'DeleteSpuriousContactPanelOpenedEvents')

Constant Summary collapse

BATCH_SIZE =

visit_events has no index on name; iterate by primary key in batches.

10_000

Delegated Instance Attributes collapse

Instance Method Summary collapse

Instance Method Details

#collectionObject



28
29
30
# File 'lib/online_migrations/data_migrations/delete_spurious_contact_panel_opened_events.rb', line 28

def collection
  scope.in_batches(of: BATCH_SIZE)
end

#countObject

Alias for Scope#count

Returns:

  • (Object)

    Scope#count

See Also:



36
# File 'lib/online_migrations/data_migrations/delete_spurious_contact_panel_opened_events.rb', line 36

delegate :count, to: :scope

#process(events) ⇒ Object



32
33
34
# File 'lib/online_migrations/data_migrations/delete_spurious_contact_panel_opened_events.rb', line 32

def process(events)
  events.delete_all
end