Last active
June 15, 2021 13:36
-
-
Save criess/38d50d51128e52d300c832f57e6658a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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