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

Reload product before assigning images to variants #3389

Merged
merged 4 commits into from
Oct 26, 2019

Conversation

JDutil
Copy link
Contributor

@JDutil JDutil commented Oct 23, 2019

Description

While this doesn't actually fix the underlying problem as I wasn't able to determine what it was these changes appear to fix the flakiness of the sample loading (in my dev environment anyways).

This change adds a reload to products before assigning their variant images on the sample seeds loading.

It also implements a couple minor rubocop and performance improvements noticed while troubleshooting the issue.

  • Adds include statements to improve asset sample file performance, which also fixed option value lookup for the solidus_tshirt & solidus_long products.
  • Unfortunately the include statements just moved the bug to the solidus_girly product, but adding a reload before the variant lookup which fixed all three products works as a hack to fix the issue.
  • Fixes Rubocop guard clause warnings
  • Removes unused option value loading

Fixes #2978

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

@kennyadsl
Copy link
Member

@JDutil I think failures will be fixed rebasing against master, thanks!

Currently Rubocop raises the following warning:
Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.

Adding empty lines around the return statements fixes them.
These option values are not being used the variant seeds, and
therefore we don't need to fetch them from the database.
When fetching products from the database before assigning images
we should include the variants, and option values to avoid n+1
database queries.
After adding the variant & option value includes within commit
81ddee979595150df708299e484f8e6ad583ec9c the failure to find option
value bug moved to the solidus_girly product. I have no idea why, but
simply reloading the product fixes the issue which was my original
solution before adding the includes. This doesn't fix whatever the
underlying issue is, but is a simple hack that seems to resolve the
flakey failures during the sample loading.
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks, @JDutil!

Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@JDutil thank you 👍

@kennyadsl kennyadsl merged commit a591fdf into solidusio:master Oct 26, 2019
@JDutil JDutil deleted the fix-2978 branch October 28, 2019 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rake task for seeding sandbox app aborted
3 participants