Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save criess/38d50d51128e52d300c832f57e6658a2 to your computer and use it in GitHub Desktop.
Save criess/38d50d51128e52d300c832f57e6658a2 to your computer and use it in GitHub Desktop.
force_delete = ARGV.find { |x| x == '--force-delete' }
from_date = Date.new(2021,4,1)
filter_item_type = 'BuyingProfile'
def lookup_lli(event)
LongListItem.find(event.context_id)
end
AnalyticsEvent.where(context_scope: :LongListItem)
.where('analytics_events.created_at >= ?', from_date).select do |o|
lookup_lli(o).item_type == filter_item_type
end.each do |o|
l = lookup_lli(o)
puts([
'ANALYTICS_EVENT', o.created_at.iso8601, o.category, o.label, o.action,
l.selling_profile.id, l.selling_profile.internal_title ,l.item.id,
l.item.title
].join(';'))
o.destroy! if force_delete
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment