-
Notifications
You must be signed in to change notification settings - Fork 19
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
added new task and test for replace new status for locked domains #2163
added new task and test for replace new status for locked domains #2163
Conversation
Changes preview: |
b2f174e
to
b4213c7
Compare
@@ -0,0 +1,55 @@ | |||
class ReplaceUpdToObjUpdProhibitedJob < ApplicationJob | |||
def perform(mode, rollback = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using keyword arguments when argument's count is more than one.
def perform(mode, rollback = false) | ||
logger.info 'Ran ReplaceUpdToObjUpdProhibitedJob!' | ||
|
||
start_adding_new_status_for_locked_domains(mode, rollback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
|
||
domain_batches.each do |domain| | ||
if domain.locked_by_registrant? | ||
if rollback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid nested conditions.
desc 'Add serverObjUpdateProhibited for locked domains' | ||
task add_new_status: :environment do | ||
time = Benchmark.realtime do | ||
ReplaceUpdToObjUpdProhibitedJob.perform_later('add') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using symbols instead of strings as arguments, preferably like perform_later(action: :add)
or (action: :remove)
end | ||
|
||
def rollback_actions(action:, domain:) | ||
if action == :add and !domain.statuses.include? 'serverUpdateProhibited' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not tweaking execution flow here, so it's better to use &&
instead of and
logger.info "Proccesing #{count} domains of #{Domain.count}" | ||
|
||
domain_batches.each do |domain| | ||
if domain.locked_by_registrant? && rollback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this block to private method which gets domain
as an argument - thus we'll lower the overall complexity
3f2bc44
to
568a142
Compare
INSTRUCTIONS:
|
84894e2
to
c34e775
Compare
No description provided.