Conversation
5b282e6 to
3649a88
Compare
| assert_true metrics.each_with_index.all? do |metric, idx| | ||
| ascendants = Metric.ascendants(service_id, metric.name) | ||
|
|
||
| if idx == 0 |
There was a problem hiding this comment.
This can be simplified using take(idx).
There was a problem hiding this comment.
yes, are you changing it?
| end | ||
| end | ||
|
|
||
| # Returns the "ascendants" of a metric, that is, its parents, |
There was a problem hiding this comment.
can a metric have multiple parents?
There was a problem hiding this comment.
yep, this was meant to correct the parents to parent, grandparent, ...
There was a problem hiding this comment.
Right. The description is not accurate 👍
|
|
||
| parents_of_metric.reduce(parents_of_metric) do |acc, parent| | ||
| acc + ascendants(service_id, parent) | ||
| end |
There was a problem hiding this comment.
Have you considered using parents_of_metric.each and pushing to it as you go for a more readable and performant version avoiding recursion?
There was a problem hiding this comment.
Not sure I follow. Can you expand a bit?
There was a problem hiding this comment.
There was a problem hiding this comment.
This is the exact same code as descendants - have you checked out how to DRY this up?
There was a problem hiding this comment.
I haven't come up with anything that makes the code more readable.
There was a problem hiding this comment.
This makes me feel uneasy, but oh well.
| assert_true metrics.each_with_index.all? do |metric, idx| | ||
| ascendants = Metric.ascendants(service_id, metric.name) | ||
|
|
||
| if idx == 0 |
There was a problem hiding this comment.
yes, are you changing it?
3649a88 to
fc15a4d
Compare
… more flexible - Set usage limits optionally, so the caller can set others. - Add the plan ID to the hash returned
fc15a4d to
446ab36
Compare
|
bors r=@unleashed |
Build succeeded |
This is part of #114 . It adapts the limits header extension to work with metric hierarchies of more than 2 levels.