Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete old tipline request and fix sentry issue #1817

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/concerns/team_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def text_contains_keyword(text, value)

def get_smooch_message(pm)
smooch_message = pm.smooch_message
smooch_message.nil? ? pm.tipline_requests.last.smooch_data : smooch_message
smooch_message.nil? ? pm.tipline_requests.last&.smooch_data : smooch_message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melsawy , is the exception happenning for items that are expected to not have an associated TiplineRequest? after the fix, did you test that rules are working for tipline messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caiosba I depend on our testing to verify this one but also I'll test it manually

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed locally that it works.

end

def title_matches_regexp(pm, value, _rule_id)
Expand Down
17 changes: 17 additions & 0 deletions lib/tasks/migrate/20231122054128_migrate_tipline_requests.rake
Original file line number Diff line number Diff line change
Expand Up @@ -448,5 +448,22 @@ namespace :check do
minutes = ((Time.now.to_i - started) / 60).to_i
puts "[#{Time.now}] Done in #{minutes} minutes."
end

# Remove old tipline requests (annotations of type smooch)
# bundle exec rails check:migrate:remove_old_tipline_requests
task remove_old_tipline_requests: :environment do
started = Time.now.to_i
total = Annotation.where(annotation_type: 'smooch').count
deleted = 0
Annotation.where(annotation_type: 'smooch').find_in_batches(:batch_size => 2000) do |annotations|
ids = annotations.map(&:id)
deleted += ids.count
DynamicAnnotation::Field.where(annotation_type: 'smooch', annotation_id: ids).delete_all
Annotation.where(id: ids).delete_all
puts "\nDeleted #{deleted} / #{total}\n"
end
minutes = ((Time.now.to_i - started) / 60).to_i
puts "[#{Time.now}] Done in #{minutes} minutes."
end
end
end
Loading