-
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
Move report formatter and charting to core #19873
Move report formatter and charting to core #19873
Conversation
cc @PanSpagetka |
# * We assign the old toplevel constant to the new constant. | ||
# * We can't include rails deprecate_constant globally, so we use ruby's. | ||
Charting = ManageIQ::Reporting::Charting | ||
Object.deprecate_constant :Charting |
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.
Reviewers, let me explain this. Rails has deprecate_constant
that you can use by including ActiveSupport::Deprecation::DeprecatedConstantAccessor
in your class/module. This is great and works well in the old ReportFormatter
, see the lib/manageiq/reporting/formatter.rb. The major benefit is it tells you what is deprecated and what's the new behavior to use.
Unfortunately, you can't include that module globally, and we have two global constants, Charting
and ReportFormatter
to deprecate. Ruby has deprecate_constant
, which we can call on Object to ensure any references to Charting
ReportFormatter
at the top level do raise deprecations. The ruby version doesn't need to include any modules but it also just tells you it's deprecated without any suggestions as to the solution. I think this is the best we can do. Maybe someone knows something better?
So, here, we setup the old Constant, set to the new one and deprecate the old one.
@@ -57,4 +57,5 @@ | |||
/content @bdunne | |||
/config @jrafanie | |||
/db @agrare @carboni @bdunne | |||
/lib/manageiq/reporting @panspagetka @jrafanie |
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.
Add @PanSpagetka and I as the reviewers for this directory from a code and code loading side.
# * We assign the old toplevel constant to the new constant. | ||
# * We can't include rails deprecate_constant globally, so we use ruby's. | ||
ReportFormatter = ManageIQ::Reporting::Formatter | ||
Object.deprecate_constant :ReportFormatter |
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.
See comment on lib/charting.rb... same thing is happening here.
Can you add the typical extraction message to the first commit? Something like:
|
I updated the description with a before/after file layout tree to help visualize the changes. |
module Formatter | ||
class Converter | ||
# generate a ruport table from an array of hashes where the keys are the column names | ||
def self.hashes2table(hashes, options) |
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.
😆 Did you show this 2 @Fryguy ?
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.
beautifully_named_methods4the_win
Related to: ManageIQ#19674 (missing ReportFormatter for backend workers) ManageIQ#19863 (move code from UI-classic that can be called from either the frontend or backend) Transferred from ManageIQ/manageiq-ui-classic@24fc2be
Related to: ManageIQ#19674 (missing ReportFormatter for backend workers) ManageIQ#19863 (move code from UI-classic that can be called from either the frontend or backend)
60e76f9
to
a676763
Compare
From ManageIQ#19863 Related to: ManageIQ#19674 (missing ReportFormatter for backend workers) ManageIQ#19863 (move code from UI-classic that can be called from either the frontend or backend)
From ManageIQ#19863 Related to: ManageIQ#19674 (missing ReportFormatter for backend workers) ManageIQ#19863 (move code from UI-classic that can be called from either the frontend or backend)
a676763
to
bf0bfd4
Compare
Some comments on commits jrafanie/manageiq@2a4d36a~...bf0bfd4 spec/lib/manageiq/reporting/formatter/c3_spec.rb
spec/lib/manageiq/reporting/formatter/chart_common_spec.rb
|
Checked commits jrafanie/manageiq@2a4d36a~...bf0bfd4 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.20.0, and yamllint lib/charting.rb
lib/manageiq/reporting/charting.rb
lib/manageiq/reporting/charting/c3_charting.rb
lib/manageiq/reporting/formatter.rb
lib/manageiq/reporting/formatter/c3.rb
lib/manageiq/reporting/formatter/c3_helper.rb
lib/manageiq/reporting/formatter/c3_series.rb
lib/manageiq/reporting/formatter/chart_common.rb
lib/manageiq/reporting/formatter/html.rb
lib/manageiq/reporting/formatter/text.rb
lib/manageiq/reporting/formatter/timeline.rb
lib/manageiq/reporting/formatter/timeline_message.rb
lib/report_formatter.rb
spec/lib/manageiq/reporting/formatter/c3_spec.rb
spec/lib/manageiq/reporting/formatter/chart_common_spec.rb
spec/lib/manageiq/reporting/formatter/text_spec.rb
spec/lib/manageiq/reporting/formatter/timeline_spec.rb
spec/models/miq_widget/chart_content_spec.rb
spec/support/report_helper.rb
|
...continued
|
Note, for happy reviewing, please review the main part of the PR in commit "Namespace all the things." without whitespace changes.
This and the UI classic PR resolves: #19674 (missing ReportFormatter for backend workers)
Also, related to #19863 (move code from UI-classic that can be called from either the frontend or backend
Thanks @bdunne for some guidance on naming things and deciding if this be should a plugin or not (tldr; too many current references to classes embedded in this code so we can't plugin-ize yet)
Also, this might help visualize the layout.
Before, in ui-classic:
After, in core: