-
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
Make Widget run without timezones #14386
Conversation
I like this approach @kbrock, very nice! Checkout the failing tests Would you be able to create a test case that covers both the |
d4f2dea
to
34bf3ac
Compare
@jrafanie Failing test was one of the modified yaml files. (yay failing tests catching dev changes) So I put in tests around generating content. |
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.
Looks good, I have a few questions/suggestions.
def timezones_for_users(users) | ||
users.to_miq_a.collect(&:get_timezone).uniq.sort | ||
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.
wow, we don't use this? 🥇
app/models/miq_widget.rb
Outdated
# options[:timezone_matters] == false will skip it | ||
# TODO: detect date field in the report? | ||
def timezone_matters? | ||
options.try(:[], :timezone_matters) != false |
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.
is this a hash? Can we do options.fetch(:timezone_matters, true)
instead?
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 think that's right, default to true
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.
Unfortunately, options
can be nil.
#A pr code:
options.try(:[], :timezone_matters) != false
#B using fetch:
options ? options.fetch(:timezone_matters, true) : true
#C using fetch 2:
(options || {}).fetch(:timezone_matters, true)
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.
Wow, good point @kbrock. Personally, I'd use a guard clause to make things very explicit:
Maybe something like this:
def timezone_matters?
return true unless options
options.fetch(:timezone_matters, true)
end
If we ever make options default to an empty hash, we could easily remove that guard clause.
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 like choice C or @jrafanie's personally
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 is options ever nil?
@kbrock is there a BZ for this? does it need to be backported? |
https://bugzilla.redhat.com/show_bug.cgi?id=1251259 - think it would be good in |
report widget option to skip timezones this will no longer produce a report per timezone per group
34bf3ac
to
0a2c5f9
Compare
Checked commits kbrock/manageiq@1a4ce7f~...0a2c5f9 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Make Widget run without timezones (cherry picked from commit c9cf152) https://bugzilla.redhat.com/show_bug.cgi?id=1434150
Euwe backport details:
|
Summary
A
Widget
is basically aReport
that is customized for a user's security group and time zone.Before
Some report data is different for each time zone.
So all reports are run for each user security group and each time zone.
Note: only time zones that are used by users in the security group are populated.
Change
But many reports just show tallies that are the same regardless of the user's time zone.
This PR marks widgets that are not affected by time zone, so they can be run once per time zone.
Conclusion
For my test customer:
50% less time is spent running these 3 reports.
The 10 minute savings per hour is 20% less load on the reporting worker.
Numbers
* before and after are estimated. Took too much time to run these.
Related items