-
Notifications
You must be signed in to change notification settings - Fork 368
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
Ensure journal is empty #463
Ensure journal is empty #463
Conversation
284a784
to
aafb78f
Compare
The code looks ok. I sent you a few small remarks in DM. Let's after green build. |
08f78fa
to
416c816
Compare
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.
Couple possible improvements. Nice testing 😄
else | ||
compose_children(result, *objects) | ||
end if children.present? && !multi_field? | ||
if children.present? && !multi_field? |
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.
Please consider splitting whole compose
method as my eyes are bleeding:
def compose(object, *parent_objects)
{ name => compose_result(object, parent_objects) }
end
def compose_result(object, *parent_objects)
objects = ([object] + parent_objects.flatten).uniq
result = base_result(object, objects)
return compose_result_with_children(result, objects) if children.present? && !multi_field?
result
end
def base_result(object, objects)
if value && value.is_a?(Proc)
result_from_proc(object, objects)
elsif object.is_a?(Hash)
result_from_hash(object)
else
object.send(name)
end
end
def result_from_proc(object, objects)
if value.arity.zero?
object.instance_exec(&value)
elsif value.arity < 0
value.call(*object)
else
value.call(*objects.first(value.arity))
end
end
def result_from_hash(object)
if object.key?(name)
object[name]
else
object[name.to_s]
end
end
def compose_result_with_children(result, objects)
if result.respond_to?(:to_ary)
result.to_ary.map { |item| compose_children(item, *objects) }
else
compose_children(result, *objects)
end
end
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.
it is not connected to my changes) this was changed to make Rubocop happy
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.
Can you please prepare follow-up PR after merging this one?
return if respond_to?(type_class.type_name) | ||
class_eval <<-METHOD, __FILE__, __LINE__ + 1 | ||
def self.#{type_class.type_name} | ||
ActiveSupport::Deprecation.warn("`#{self}.#{type_class.type_name}` accessor is deprecated and will be removed soon. Use `#{type_class}` directly instead.") |
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.
Please break this long line by using heredoc:
ActiveSupport::Deprecation.warn(<<WARNING.sqish)
`#{self}.#{type_class.type_name}` accessor is deprecated and will be removed soon.
Use `#{type_class}` directly instead.
WARNING
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.
it is not connected to my changes) this was changed to make Rubocop happy
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.
Can you please prepare follow-up PR after merging this one?
def until(time) | ||
query = Query.new(time, :lte, nil, false).to_h | ||
search_query = query.merge(fields: ['_id'], size: DELETE_BATCH_SIZE) | ||
index_name = Journal.index_name |
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 can use delegation:
included do
delegate :index_name, to: Journal
end
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.
actually, I think that explicit calls are easier) longer, but easier)
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.
OK
end | ||
end | ||
|
||
Chewy.massacre |
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.
😅
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.
🚢 🇮🇹
3158ecb
to
442d015
Compare
7b9f420
to
3162659
Compare
Refactor
Chewy::Journal
Add multiple retries to apply the journal