-
Notifications
You must be signed in to change notification settings - Fork 897
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
Memoize cols_on_metric_rollup in chargeback #17927
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,9 @@ def rate_name | |
end | ||
|
||
def self.cols_on_metric_rollup | ||
(%w(id tag_names resource_id) + chargeable_cols_on_metric_rollup).uniq | ||
@cols_on_metric_rollup ||= begin | ||
(%w(id tag_names resource_id) + chargeable_cols_on_metric_rollup).uniq | ||
end | ||
end | ||
|
||
def self.col_index(column) | ||
|
@@ -136,8 +138,10 @@ def self.seed_data | |
end | ||
|
||
def self.chargeable_cols_on_metric_rollup | ||
existing_cols = MetricRollup.attribute_names | ||
chargeable_cols = pluck(:metric) & existing_cols | ||
chargeable_cols.map! { |x| VIRTUAL_COL_USES[x] || x }.sort | ||
@chargeable_cols_on_metric_rollup ||= begin | ||
existing_cols = MetricRollup.attribute_names | ||
chargeable_cols = pluck(:metric) & existing_cols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @libor, I think this line may be causing the sporadic test failures. If this code is called before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes! and finally I probably found a culprit. thanks |
||
chargeable_cols.map! { |x| VIRTUAL_COL_USES[x] || x }.sort.uniq | ||
end | ||
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.
Could new records be created with new data in the
metric
column that would never be seen?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.
Yes but not during running application. It could be added only by adding record (this happens very rarely) to chargeable_field.yml and based on the yaml, table chargeable_field table is filled up in the seed process.
thanks