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

Properly generate report yml include with virtual attributes #18205

Merged
merged 1 commit into from
Nov 29, 2018

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Nov 15, 2018

Problem

Before

If a report.yml file had virtual attributes in the :cols but did not have an :include entry,
it was not properly generating the includes().references() hash.

REMINDER: report.yml files are used to represent every data view in our product.

After

It is now generating the correct :includes from :col_order when :include is not defined,
regardless of whether :col contains virtual attributes or not.

Impact

We are constantly tuning the app/model classes. Sometimes the relations change (e.g.: pictures no longer points to binary_blobs) and other times the virtual attributes are embeddable in sql. So this means the correct includes()/references() values change.

Since the report.yml files are in a different git repo, they are often not updated. This means extra data gets downloaded, or in some cases, just plain break. Which happened with ServiceTemplate.yml.

The frustrating part is the includes entries can just be derived from the app/model class relationships, and shouldn't even need to be declared in the report.yml files in the first place.

Conclusion

Properly generating the includes() allows us to remove more of the :include entries from the reports, and that means we have fewer incorrect reports / views. And it means faster views.

/cc @jrafanie @martinpovolny

@kbrock kbrock force-pushed the report_generate_includes branch 2 times, most recently from e96d09c to c97e707 Compare November 15, 2018 17:40
@Fryguy
Copy link
Member

Fryguy commented Nov 15, 2018

I love this change so much...can we remove the "includes" sections from the report.yml files after this? I would love to kill an entire section

*rels, _col = col.split(".")
rels.inject(ret) { |h, rel| h[rel.to_sym] ||= {} } unless col =~ /managed\./
end
include_as_hash(include.presence || invent_report_includes).deep_merge(include_for_find || {}).presence
Copy link
Member

Choose a reason for hiding this comment

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

My question in #18205 (comment) is really asking, can we remove include.presence from this section entirely?

Copy link
Member Author

@kbrock kbrock Nov 15, 2018

Choose a reason for hiding this comment

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

users tend to copy paste the report templates, and most of the report views have a blank include block. Of our 180 reports, 95 are a blank hash.

$ ag -l '^include:\n\n' product/views/ | wc -l
      95
$ ag -l '^include:\n' product/views/ | wc -l
     170
$ find product/views | wc -l
     180

@kbrock
Copy link
Member Author

kbrock commented Nov 15, 2018

@Fryguy Full disclaimer.

I tried to do this in the past #13675
And it blew up / so I had to revert a bunch of them #14439

So there may still be dragons here.
I'm pretty sure introducing this change works now. but will do my best to track down the trouble makers.

@kbrock kbrock force-pushed the report_generate_includes branch from c97e707 to e7e781a Compare November 15, 2018 20:42
@kbrock
Copy link
Member Author

kbrock commented Nov 19, 2018

@Fryguy Sweet. This is working.

For OrchestrationStack.yml - which has ext_management_system.name and total_cloud_networks (non-sql friendly virtual attributes) show the same values and perform the same queries after I remove the columns and includes values.

Unlike the last time I tried to make this change, the columns on associations (e.g.: ext_management_systems.name) show up in the final screen.

@kbrock kbrock force-pushed the report_generate_includes branch from e7e781a to 1d26993 Compare November 19, 2018 23:38
If a report yml file has virtual attributes in the cols and no :include
it was not generating the proper includes hash.

Now it is generating the includes from :col_order or :include
regardless of whether virtual attributes are in the col (or col_order)

leaving invent_includes around for report_sanity_checker
@kbrock kbrock force-pushed the report_generate_includes branch from 1d26993 to 1b31bd7 Compare November 19, 2018 23:41
@kbrock
Copy link
Member Author

kbrock commented Nov 19, 2018

@Fryguy changed some comments to actual tests. Are you good to go with this PR?

@miq-bot
Copy link
Member

miq-bot commented Nov 19, 2018

Checked commit kbrock@1b31bd7 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@kbrock
Copy link
Member Author

kbrock commented Nov 20, 2018

Ugh. Rebasing onto red master strikes again

@Fryguy
Copy link
Member

Fryguy commented Nov 29, 2018

This one has the potential to break the UI...can you verify that the UI tests pass with this PR?

cc @himdel (This is where I would have liked to do @miq-bot test-plugin manageiq-ui-classic 😉 ...btw, that test framework is in the process of being built)

Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

LGTM, pending UI test verification.

@kbrock
Copy link
Member Author

kbrock commented Nov 29, 2018

What this effects:

  1. Have no includes: defined in the report (8 of the 180 view reports)
  2. Have cols defined (all of our views)
  3. Have virtual attributes that are ruby only (sql virtual attributes are ok) (3 of those 8)
  4. Reference other tables (dots) in the col_order (0 of those 8)

And this makes sense, because if we did have any of those, they would be broken already.
This PR simply fixes reports that fall under that case (which we avoided since it is broken)

Hmm. Little confused this bug bit us so badly, since if we tend to remove the cols and the includes at the same time. I guess it only comes into play when we want to bring down a column that is not displayed e.g.: picture.id

@Fryguy Fryguy merged commit f10559f into ManageIQ:master Nov 29, 2018
@Fryguy Fryguy added this to the Sprint 100 Ending Dec 3, 2018 milestone Nov 29, 2018
@kbrock kbrock deleted the report_generate_includes branch November 29, 2018 21:50
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.

3 participants