-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add column report_base_model to ChargebackRate table #209
Add column report_base_model to ChargebackRate table #209
Conversation
3ea45d0
to
57100e3
Compare
Checked commit hstastna@57100e3 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@gtanzillo are you ok with this ? if naming is correct ? Thanks! |
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.
👍
@lpichler @gtanzillo Any update about this PR? Thanks! ;) |
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.
👍 @Fryguy you ok with merging this change?
I'm not sure about this one...something feels off about the design...can we discuss? |
So let's discuss :) .. We need this PR to be merged to implement this: ManageIQ/manageiq-ui-classic#4001 (screenshots included) |
@Fryguy yes are right, Let me bring some facts: These days as you know we have 3 types of chargeback reports: for VMs/Images/Projects. This information is now done at application level by this hash. in ChargebackVm, ChargebackContainerImage, ChargebackContainerProject. It looks that we don't need to extra store this type in ChargebackRate table. We rather want to know which column is related to which types. ChargebackRate are always related to particular report type. but if we go deeper the chargeback field are making the relations to chargeback report type. We can think about these three options:1) Store report type in ChargebackRate 2) Store report type in ChargebackReportType 3) Leave as it is and use application code Note (or option 4): Of course, there are more ways to reach this with IFs in UI. But this has primary reason: Don`t mess up the (UI //cc @martinpovolny ) code if there is a chance to make it clean with database changes. @hstastna if I forgot something or if you see different way let us know. @Fryguy which option are you prefer ? I am starting to prefer option 2. thanks |
+1 for option 2. Based on what I've read, the issue you're trying to solve is that different models have different fields associated with them and we should only display the fields for the selected model when building a report, right? (If this is wrong then just let me know and disregard my opinion here 😆 ) A lookup table for model names could be a good solution for this, but I wonder if there is any other place that we store what metrics apply to what model? Do we have the concept of "metric types" that we can link here instead of using a metric string? That would probably be a more useful solution generally, but definitely not suggesting we build that for this PR if it doesn't exist currently. |
@lpichler @Fryguy @carbonin @gtanzillo Any update about this? Does it mean that we have chosen option 2? Thanks! :) |
I am generally not a fan of storing model names in the database unless they are part of a polymorphic association (and thus Rails takes care of it), and that's part of the reason for my initial concern. That being said, in this particular case, there are only 3 specific models and they are all subclasses of Chargeback, so the scope of what can be stored here is limited and can probably even be mitigated with a model validation to ensure only those types are stored there. Additionally, those 3 models are not actual models, but ActsAsArModel types, so they couldn't be stored via polymorphic relations anyway. Given all that I'm good with option 2. |
@Fryguy Just to be clear, I don't think this PR actually implements Libor's option 2. |
Ahh, maybe I had better to move this PR to WIP. Because originally, option 1 was implemented and then we started discussion about another options and I was waiting for others to choose the best option, before making any change in this PR. But now, maybe option 1 is not the worst (it was approved) :D |
Gah I totally misread the PR. I saw it adding the column to chargeable_rates, but when I read option 2 I saw it say chargeable_fields and was like "yup, that's what the PR is doing...merge".
EDIT: Fixed the author...I knew I shouldn't have been doing any actual work the day after vacation 😆 |
Just a note that this PR was 'reverted'. |
Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1581817
What:
We need to store the type of the Rate which is related to type of Report: Chargeback for VMs/Images/Projects.
Why:
We need it for adding new drop down to editing screen for Rate to be able to choose the type of the rate and then to display only appropriate columns of the rate, based on the chosen type of the rate (VMs, Images, Projects).
Additional note:
This PR was, let's say, 'reverted' by #270