Skip to content
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 scopes selector for MiqTasks #2521

Merged
merged 3 commits into from Oct 30, 2017

Conversation

tumido
Copy link
Member

@tumido tumido commented Oct 26, 2017

Copy the tasks_condition behavior, but return :named_scopes instead of :conditions.

In future replace the tasks_condition method, when possible.

Depends on: ManageIQ/manageiq/pull/16308, ManageIQ/manageiq#16323
Should help with: #2383

@tumido
Copy link
Member Author

tumido commented Oct 26, 2017

cc @martinpovolny


statuses = (opts.keys & status_scopes.keys)
if statuses.any?
statuses.each { |status| scope += status_scope[status] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can and should use reduce here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skateman, sure I will, give me 1 hour. :P

@martinpovolny
Copy link
Member

@skateman, @mzazrivec, @tumido : tested? working?

rspec ./spec/controllers/miq_task_controller_spec.rb:827 # MiqTaskController#tasks_condition #list_jobs sets the active tab

Looks related :-(

@martinpovolny
Copy link
Member

@skateman : otherwise tested, reviewed?

@skateman
Copy link
Member

@tumido I was wrapping my head around this and I understand it more or less, but I think this would need some extra description above the method and some specs. I was also clicking through the UI and found out that the filtering doesn't work at all with your changes 😞

It seems like the tasks_scopes(@tasks_options[@tabform]) always returns nil

@@ -79,7 +79,8 @@ def list_jobs
when "tasks_2", "alltasks_2" then @layout = "all_tasks"
end

@view, @pages = get_view(MiqTask, :conditions => tasks_condition(@tasks_options[@tabform]))
binding.pry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☠️ ☠️ ☠️ 🚒 🚽

@tumido
Copy link
Member Author

tumido commented Oct 27, 2017

Newly depends on ManageIQ/manageiq#16323

@tumido
Copy link
Member Author

tumido commented Oct 27, 2017

Since we can't effectively build scoped queried for state and status attributes, this functionality has been removed. For now, the data returned are not filtered based on state or status. The problem we're facing here is that the original query looks like

["miq_tasks.userid=? AND ((miq_tasks.state=? OR miq_tasks.state=?) OR (miq_tasks.state=? AND miq_tasks.status=?) OR (miq_tasks.state=? AND miq_tasks.status=?) OR (miq_tasks.state=? AND miq_tasks.status=?) OR (miq_tasks.state!=? AND miq_tasks.state!=? AND miq_tasks.state!=?)) AND miq_tasks.updated_on>=? AND miq_tasks.updated_on<=?",
 "admin",
 "Waiting_to_start",
 "Queued",
 "Finished",
 "Ok",
 "Finished",
 "Error",
 "Finished",
 "Warn",
 "Finished",
 "Waiting_to_start",
 "Queued",
 Fri, 27 Oct 2017 00:00:00 UTC +00:00,
 Fri, 27 Oct 2017 23:59:59 UTC +00:00]

If you look closely you can see we have here ANDed queries for userid, <state and status>, updated_on. And the <state and status> has mix of ORs and ANDs inside. Which is pain for scopes. I can't find a way how to do it properly now, so this filtering is avoided for now.

@abonas
Copy link
Member

abonas commented Oct 30, 2017

what is the status of this PR? is it needed for the upcoming release?

@tumido
Copy link
Member Author

tumido commented Oct 30, 2017

@abonas, yes. But not by our team, It's needed by @martinpovolny.

@abonas
Copy link
Member

abonas commented Oct 30, 2017

so is it waiting for review/merge?
@martinpovolny what feature is this needed for?
(feature freeze is super close)

@martinpovolny
Copy link
Member

@abonas : this is needed for the GTLs to work correctly. This needs to go to the release. There's a set of > 10 PRs and this one is one of those. Once travis is green, this is merged.

Copy the `tasks_condition` behavior, but return `:named_scopes` instead
of `:conditions`.

In future replace the `tasks_condition` method, when possible.
@miq-bot
Copy link
Member

miq-bot commented Oct 30, 2017

Checked commits tumido/manageiq-ui-classic@f6f2dc4~...5277449 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 1 offense detected

app/controllers/miq_task_controller.rb

  • ❗ - Line 360, Col 93 - Rails/TimeZone - Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.to_i, Time.now.to_f instead.

@martinpovolny
Copy link
Member

Ignoring failed chargeback test.

@martinpovolny martinpovolny merged commit 26fe19b into ManageIQ:master Oct 30, 2017
@martinpovolny martinpovolny added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 30, 2017
@martinpovolny martinpovolny self-assigned this Oct 30, 2017
@tumido tumido deleted the condition_to_scope2 branch June 26, 2018 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants