-
Notifications
You must be signed in to change notification settings - Fork 899
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
Fix error when viewing timelines in Optimize-Bottlenecks in IE #3529
Fix error when viewing timelines in Optimize-Bottlenecks in IE #3529
Conversation
@dclarizio Fix verified in IE9 |
@bmclaughlin Can we try to consolidate the duplicated code into a common method? Thx, Dan |
@Fryguy, @tenderlove, do you have any recommendations on DRY'ing up the https://github.com/ManageIQ/manageiq/blob/master/app/controllers/dashboard_controller.rb#L597 https://github.com/ManageIQ/manageiq/pull/3529/files#diff-8c3427b37f1658d1cc09ffb1b7d975e5R67 |
Yes, we should definitely dry these up. Are they exactly the same? Just at a glance they look very similar. We should extract a function with the similar things, then extract the different bits. Sorry, that's a little vague, but essentially we should use the Extract Method technique a couple times. I can show you a patch to get you started if that helps! |
Not exactly the same, I found a one line difference that will be easily solved with one parameter. I wasn't sure where the best home for the extracted method would be (application helper or application controller?)? |
@bmclaughlin well it looks like this method creates XML that is only to do with VM instances. I would either move it to a |
3af69c2
to
bbfbe7d
Compare
@@ -0,0 +1,12 @@ | |||
class VmPresenter | |||
def initialize(controller, session) | |||
@controller = controller |
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.
Why do we pass in the controller into this class if we do not use it? Is that some sort of pattern for presenters?
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.
In reading here and here and here, this object should be initialized with a Vm
, but instead, is getting a controller and session. It is not using the controller and I don't think it should be using the session. What does session[:tl_xml_blob_id]
represent?
@tenderlove @matthewd @Fryguy Please comment on how we should use Presenters.
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.
I missed removing the passed in controller when refactoring the original code, thanks for catching that. The original code also made use of a Vm
but that turned out to be dead code and was removed. Now in hindsight I see that I can pass the session value directly to the function as well. I'll make these changes momentarily.
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.
Having been reduced to "get the thing from the DB object", this is no longer feeling like the place to have a presenter discussion, to me. Let's just inline the BinaryBlob.find
back into the callers.
bbfbe7d
to
66780cc
Compare
@bmclaughlin need to correct the failing spec. |
66780cc
to
df9b85d
Compare
@chessbyte @Fryguy @dclarizio @matthewd, recommended changes implemented, please review. |
... but is it even useful? AFAICS, if it's not true, we'll fail to render, and (given there's no corresponding view) still end up with an error either way. So I think we can just lose it. |
Err, we seem to have lost a |
@bmclaughlin Travis failure, seems a spec still has the CamelCased route in it. |
@matthewd, I agree on the nil check, and I lost the @dclarizio, fixed that pesky spec. |
@bmclaughlin the |
@chessbyte, apologies, thought that was destroying the object in memory. Need more coffee. Patch coming momentarily! |
bump @bmclaughlin |
@chessbyte, 'Momentarily' became slightly longer due to a double rendering issue between rendering the view and rendering the xml for IE. |
8ab1097
to
ee9c710
Compare
@chessbyte, @dclarizio this should be ready when travis finishes. |
@bmclaughlin there still seems to be code duplication between the new multiple |
@tenderlove @Fryguy @matthewd what is the best way to refactor the duplicate |
if session[:tl_xml_blob_id] != nil | ||
blob = BinaryBlob.find(session[:tl_xml_blob_id]) | ||
render :xml=>blob.binary | ||
def timeline_data |
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.
If this timeline_data
method is in ApplicationController, why do we need the duplicate methods in subclassed controllers (DashboardController and MiqCapacityController)?
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.
Indeed. Though, as it's apparently only used by three routes, I think I'd rather reduce the massive ApplicationController surface area by one method, and move it to whichever third controller is currently actually capable of getting here.
|
@chessbyte I don't think there's enough code there to duplicate, to warrant extraction. Especially if my above allegation is true. |
- DRY'd and refactored getTLdata method - added additional routing specs - Fixed double render issue caused by partial _bottlenecks_tl_detail.html.haml being rendered directly as well as indirectly via _bottlenecks_tabs.html.haml https://bugzilla.redhat.com/show_bug.cgi?id=1234588
ee9c710
to
2941dc7
Compare
@chessbyte, @matthewd Originally the miq_capacity_controller was throwing errors when trying to access the copy of timeline_data in application controller, however that seems to have been due to an intervening bug and the duplicate code is now properly DRY'd out as well as the suggested optimizations implemented. And I squashed the commits. |
Checked commit bmclaughlin@2941dc7 with rubocop 0.32.1 and haml-lint 0.13.0 |
@bmclaughlin Nice and DRY! Waiting for Travis to go green before merging. |
…ne-error Fix error when viewing timelines in Optimize-Bottlenecks in IE
@bmclaughlin I'm still missing an answer to #3529 (comment)... I don't understand what the two |
@matthewd I agree, we will still just get an error. Would you like me to remove those lines in a quick follow-up PR? |
Yeah, let's kill those two, and switch to (and while I'd generally favour |
https://bugzilla.redhat.com/show_bug.cgi?id=1234588
@dclarizio, @h-kataria please review.