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

Add validation event check force delete to a job #2369

Merged
merged 9 commits into from
May 17, 2022

Conversation

thiagoyoussef
Copy link
Member

No description provided.

@viezly
Copy link

viezly bot commented Apr 27, 2022

Changes preview:

Legend:

👀 Review pull request on Viezly

@thiagoyoussef thiagoyoussef marked this pull request as ready for review April 28, 2022 11:06
@thiagoyoussef thiagoyoussef marked this pull request as draft April 28, 2022 12:57
@thiagoyoussef thiagoyoussef force-pushed the refactor-check-force-delete branch 4 times, most recently from 6607dfb to 930f6ac Compare May 2, 2022 12:51
@thiagoyoussef thiagoyoussef marked this pull request as ready for review May 2, 2022 12:58
@@ -0,0 +1,40 @@
class ValidationEventCheckForceDeleteJob < ApplicationJob
Copy link
Member Author

Choose a reason for hiding this comment

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

change the name

task check_force_delete: :environment do
invalid_contacts = Contact.joins(:validation_events).select do |contact|
events = contact.validation_events
events.mx.count >= 3 || events.regex.present?
Copy link
Member Author

Choose a reason for hiding this comment

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

Use MX_CHECK

Copy link
Member Author

@thiagoyoussef thiagoyoussef May 3, 2022

Choose a reason for hiding this comment

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

Check invalid events only

@@ -0,0 +1,11 @@
desc 'Check Force Delete'
task check_force_delete: :environment do
Copy link
Member Author

Choose a reason for hiding this comment

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

Add args to use batches and schedule delay between jobs

@vohmar
Copy link
Contributor

vohmar commented May 5, 2022

To run the job you need to execute the rake task check_force_delete
3 optional arguments to call the task:

  • batch - value can be true or false - default value is false - true: executes the job in batches, one job = many contacts - false: one job = one contact - this way Martin can see which one performs better
  • batch_size - number of contacts that will be performed in each job - default 1000
  • batches_delay - minutes between each job that will be performed - default 15 minutes

It's possible to call the task like this:

  • rake check_force_delete - will perform without batch, one contact = one job
  • rake 'check_force_delete[true, 10000]' - will perform with batch, 10000 contacts = one job, with 15 minutes of difference between jobs
  • rake 'check_force_delete[true, 10000, 30]' - will perform with batch, 10000 contacts = one job, with 30 minutes of difference between jobs

@vohmar vohmar merged commit ac46637 into master May 17, 2022
@vohmar vohmar added the refactor Refactoring of existing feature label May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants