-
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
Add status and state scopes, fix time for MiqTask list #16365
Conversation
app/models/miq_task.rb
Outdated
scope :completed_warn, -> { finished.where(:status => 'Warn') } | ||
scope :completed_error, -> { finished.where(:status => 'Error') } | ||
scope :no_status_selected, -> { running.where.not(:status => %(Ok Error Warn)) } | ||
scope :with_status_in, ->(scopes) { scopes[1..-1].reduce(MiqTask.send(scopes.first)) { |chain, s| chain.or(MiqTask.send(s)) } } |
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.
This is not the most handsome scope out there, I have to admit that. It allows us to chain scopes to get a query like:
scope1 AND scope2 AND (scope3 OR scope4 OR scope5)
using scopes (matching to example above)
:named_scopes => [:scope1, :scope2, [:with_status_in, [:scope3, :scope4, :scope5]]]
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.
This is an alternative to what previously was an SQL fragment passed around. So while this is not perfect, it's a significant improvement on the current situation.
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.
The later patch uses splat instead of slices, which is a bit better code...
ffec1ca
to
f8f555e
Compare
Checked commit tumido@f8f555e with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
LGTM 👍 |
Add status and state scopes, fix time for MiqTask list (cherry picked from commit d24d6d7) https://bugzilla.redhat.com/show_bug.cgi?id=1509429
Gaprindashvili backport details:
|
Fix a regression brought by: ManageIQ/manageiq-ui-classic#2521
Related: ManageIQ/manageiq-ui-classic#2585
Adding
:state
and:status
based filtering for tasks view and fix the:updated_on
scope, since after a switch to reportdata it stopped working properly (Ruby date range can't be passed as string).