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

Load virtual custom columns from miq expression automatically #11369

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented Sep 19, 2016

Load virtual custom columns == create dynamically method which is virtual and such methods
contain loading attributes from table CustomAttribute and we are getting ability that attributes in CustomAttribute#name have behavior as normal column.

If we have some in MiqExpression we need to load them first. This PR is moving loading when MiqExpression object is created.

@miq-bot assign @gtanzillo

can you please review?
@imtayadeway @alongoldboim

WIP: requires fix: #11380 and #11415 [unmerged]

@@ -1539,6 +1551,27 @@ def self._quick_search?(e)
end
end

def custom_attribute_columns_and_models(expression = nil)
return []
Copy link
Member

Choose a reason for hiding this comment

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

short circuit? Is this PR a WIP PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Fryguy I had here some unwanted stuff

@lpichler lpichler changed the title Load virtual custom columns from miq expression automatically [WIP] Load virtual custom columns from miq expression automatically Sep 19, 2016
@lpichler lpichler force-pushed the load_virtual_custom_columns_from_miq_expression branch from ed003ce to b17c012 Compare September 19, 2016 16:31
@lpichler
Copy link
Contributor Author

lpichler commented Sep 19, 2016

@kbrock is it ok regard to perfomance ? methods for virtual custom attributes are created only when MiqExpression object is created and when there are already defined the creation is skipped. It is also finding recursively virtual_custom_attributes in expression for each MiqExpression object.

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

Trying to wrap my mind around this.

Not sure if we need to work so hard to be lazy about these.

We are taking the hit on creation of the MiqExpression when the MiqExpression only has a custom attribute in it. So this looks good to me.

Let me know when this is no longer WIP

@@ -34,6 +34,8 @@ def self.load_custom_attributes_for(cols)
end

def self.add_custom_attribute(custom_attribute)
return if respond_to?(custom_attribute)
Copy link
Member

Choose a reason for hiding this comment

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

this is great

@lpichler lpichler force-pushed the load_virtual_custom_columns_from_miq_expression branch 2 times, most recently from d8fa377 to 4ba36ca Compare September 21, 2016 09:15
@lpichler lpichler force-pushed the load_virtual_custom_columns_from_miq_expression branch from 4ba36ca to d2e7ca5 Compare September 21, 2016 11:33
@lpichler
Copy link
Contributor Author

at this moment depends on #11415

@lpichler lpichler force-pushed the load_virtual_custom_columns_from_miq_expression branch from d2e7ca5 to 6880499 Compare September 21, 2016 16:59
@lpichler lpichler changed the title [WIP] Load virtual custom columns from miq expression automatically Load virtual custom columns from miq expression automatically Sep 21, 2016
@lpichler
Copy link
Contributor Author

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Sep 21, 2016
@lpichler
Copy link
Contributor Author

@kbrock @alongoldboim @imtayadeway - rebased and I added catching of expection.

@kbrock kbrock removed their assignment Sep 22, 2016
@kbrock
Copy link
Member

kbrock commented Sep 22, 2016

I'm good with this. I'll merge if @imtayadeway or @gtanzillo give a +1


it "automatically loads virtual custom attributes from MiqExpression on class" do
MiqExpression.new("EQUAL" => {"field" => "#{klass}-#{virtual_custom_attribute}", "value" => "foo"}).to_sql
expect(vm).to respond_to(virtual_custom_attribute)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to prove that it was the line above that made this so?

Copy link
Contributor Author

@lpichler lpichler Sep 22, 2016

Choose a reason for hiding this comment

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

@imtayadeway I am not sure how to prove it.
maybe ?

 expect(vm).not_to respond_to(virtual_custom_attribute)
 MiqExpression.new("EQUAL" => {"field" => "#{klass}-#{virtual_custom_attribute}", "value" => "foo"}).to_sql
 expect(vm).to respond_to(virtual_custom_attribute)

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that better 👍

Could also be:

expect {
  MiqExpression.new(...)
}.to change { vm.respond_to?(virtual_custom_attrivute) }.from(false).to(true)

But whichever you prefer :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@imtayadeway I prefer change 👍 thanks

@lpichler lpichler force-pushed the load_virtual_custom_columns_from_miq_expression branch from 6880499 to 985ca22 Compare September 22, 2016 11:55
@miq-bot
Copy link
Member

miq-bot commented Sep 22, 2016

Checked commits lpichler/manageiq@062ad5e~...985ca22 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 3 offenses detected

lib/miq_expression.rb

@lpichler
Copy link
Contributor Author

lpichler commented Oct 5, 2016

@gtanzillo can it be merged, if it looks good to you ? thanks!

@alongoldboim need it for #11002

@alongoldboim
Copy link
Contributor

LGTM 👍

@gtanzillo
Copy link
Member

👍 LGTM

@gtanzillo gtanzillo added this to the Sprint 48 Ending Oct 24, 2016 milestone Oct 5, 2016
@gtanzillo
Copy link
Member

@lpichler I've tagged as euwe/no. Let me know if this is not correct.

@gtanzillo gtanzillo merged commit 10d93a4 into ManageIQ:master Oct 5, 2016
lpichler added a commit to lpichler/manageiq that referenced this pull request Oct 10, 2016
we are loading virtual custom columns from MiqExpression
when MiqExpression object is created
ManageIQ#11369
@lpichler lpichler deleted the load_virtual_custom_columns_from_miq_expression branch October 14, 2016 09:31
@lpichler
Copy link
Contributor Author

@gtanzillo this should be euwe/yes, @alongoldboim's related PR are also euwe/yes

@miq-bot add_label euwe/yes

lpichler added a commit to lpichler/manageiq that referenced this pull request Oct 14, 2016
we are loading virtual custom columns from MiqExpression
when MiqExpression object is created
ManageIQ#11369

(cherry picked from commit 26f94a1)
@lpichler
Copy link
Contributor Author

lpichler commented Oct 14, 2016

@miq-bot remove_label euwe/no

@miq-bot miq-bot removed the euwe/no label Oct 14, 2016
chessbyte pushed a commit that referenced this pull request Oct 14, 2016
…rom_miq_expression

Load virtual custom columns from miq expression automatically
(cherry picked from commit 10d93a4)
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log -1
commit e7832969d7eef5c2e228ddc71a05955d1fab6396
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Wed Oct 5 18:18:29 2016 -0400

    Merge pull request #11369 from lpichler/load_virtual_custom_columns_from_miq_expression

    Load virtual custom columns from miq expression automatically
    (cherry picked from commit 10d93a4a5761a3b5402fba20fccb1d807c51e174)

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

8 participants