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

introduce User.lower_userid to remove some arel across a few repos #20532

Merged
merged 2 commits into from
Jan 14, 2021

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Sep 9, 2020

I noticed a few lowercase comparisons for userid and a lookup by userid method

this allows us to just use active record where instead of the arel junk.

# before a
    where(arel_table.grouping(Arel::Nodes::NamedFunction.new("LOWER", [arel_attribute(:userid)]).eq(userid.downcase)))
before b
    where('lower(userid) = ?', userid.downcase)
# after
    where(:lower_userid => userid.downcase)

I would prefer if we used this instead of lookup_by_name() but want a second opinion on that one before moving forward. specifically the in region filter.

this is developer focused

userid&.downcase
end

virtual_attribute :lower_userid, :string, :arel => ->(t) { t.grouping(t[:userid].lower) }
Copy link
Member

Choose a reason for hiding this comment

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

Only thing I don't like about this is that it's now exposed to reporting.

Copy link
Member Author

@kbrock kbrock Sep 10, 2020

Choose a reason for hiding this comment

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

we need to come up with a way to hide attributes from reporting and from the api
This is also useful when we want to deprecate a fields. Have them work but not show up in the drop downs/documentation

I have had an idea mulling in my head for a while, but never know if this is viable or not - due to the complexity of add ing a concept that isn't really in rails at this time. attributes and hidden_attributes kinda like methods (privatet_methods) and public_methods?

Copy link
Member

@Fryguy Fryguy Sep 10, 2020

Choose a reason for hiding this comment

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

I like the public/private designation idea. What if we just literally make them private, then in reporting, as we enumerate the methods we only take public virtual methods?

private

virtual_attribute :lower_userid, :string, :arel => ->(t) { t.grouping(t[:userid].lower) }

and/or

private virtual_attribute :lower_userid, :string, :arel => ->(t) { t.grouping(t[:userid].lower) }

Copy link
Member Author

Choose a reason for hiding this comment

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

If we are using send to call these parameters, then that will require changes in using them
but when we are constructing the api or the drop down, we can look at them.

Nice to not introduce any new metadata

I do wonder how this will work if we use the class when it hasn't been used yet. the attributes may not be defined yet.

will look into this

@kbrock kbrock changed the title introduce User.lower_userid to remove some arel across a few repos [WIP] introduce User.lower_userid to remove some arel across a few repos Sep 10, 2020
@kbrock kbrock added the wip label Sep 10, 2020
@kbrock
Copy link
Member Author

kbrock commented Sep 10, 2020

wipping until we find a good way to hide attributes in the api and report builder

kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 6, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

This allows attributes to still work, but just not be advertised on our public apis (i.e.: report builder and rest api). This allows 

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 6, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

This allows attributes to still work, but just not be advertised on our public apis (i.e.: report builder and rest api). This allows

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 7, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.


This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 7, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 23, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Oct 23, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 2, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 3, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 3, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised to the customer
     as attributes to use.

After this change, the attributes are still accessible. Just these attributes
are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes.

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised to the customer
     as attributes to use.

After this change, the attributes are still accessible. Just these attributes
are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes.

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
kbrock added a commit to kbrock/manageiq that referenced this pull request Nov 12, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised to the customer
     as attributes to use.

After this change, the attributes are still accessible. Just these attributes
are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes.

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
@kbrock
Copy link
Member Author

kbrock commented Nov 13, 2020

status: will hide this attribute using #20664
still waiting on that going through

kbrock added a commit to kbrock/manageiq that referenced this pull request Dec 8, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised to the customer
     as attributes to use.

After this change, the attributes are still accessible. Just these attributes
are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes.

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
@kbrock kbrock changed the title [WIP] introduce User.lower_userid to remove some arel across a few repos introduce User.lower_userid to remove some arel across a few repos Jan 7, 2021
@kbrock kbrock added core and removed wip labels Jan 7, 2021
@kbrock
Copy link
Member Author

kbrock commented Jan 7, 2021

updated to use hide_attribute so it is not exposed in the api (this is now part of the core)
un-wipped

@miq-bot
Copy link
Member

miq-bot commented Jan 7, 2021

Checked commits kbrock/manageiq@c30555a~...668e834 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
4 files checked, 0 offenses detected
Everything looks fine. ⭐

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

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

Looks fine to me. Seems like Jason's concern was addressed, so I think this is good to go.

Sidenote: I think lower_* reads a little weird, but seems like it is derived from the posgresql string function, so I don't think it is worth trying to do an exercise of trying to find a better name, so just leave it.

@Fryguy Fryguy merged commit a23cd5b into ManageIQ:master Jan 14, 2021
@Fryguy Fryguy self-assigned this Jan 14, 2021
@kbrock kbrock deleted the lower_name branch January 15, 2021 03:22
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.

4 participants