-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
2014 refactor variant count on hand #2413
2014 refactor variant count on hand #2413
Conversation
@sauloperez I just noticed that I repeated your commit 0cbd967. @Matt-Yorkley added that line in a503b5e. I guess that was a merge conflict mistake. |
def in_stock? | ||
return true unless Spree::Config[:track_inventory_levels] | ||
|
||
on_demand || (count_on_hand > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with variant overrides but I guess count_on_hand
is a column on a database table added by OFN, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a spree database column on both spree_product and spree_variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads-up @mkllnk: on_demand
is being removed as well in 2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Matt-Yorkley Thanks for the heads up. I wasn't sure if I considered that. But this method is only active if the variant has a VariantOverride. The VariantOverride does have on_demand
and count_on_hand
. The vanilla Spree::Variant still has an in_stock?
method in both Spree versions. So we should be safe to call it.
@mkllnk have you tried rendering any report that uses |
@sauloperez Yes, I did test that just now. But it should also be covered by our specs. What do you mean with "too early"? This is production code, going into master. |
Staged on https://staging1.openfood.com.au/. |
@myriamboure or @sstead I'm afraid I don't know very well the inventory feature to test this PR. Can one of you have a look? I will be interested in ready the testing notes afterwards. |
@mkllnk can you clarify, are we testing all 3 reports within the Products and Inventory report? I don't have anymore time to test today but here's where I'm up to so far... Issues:
I think there's some design flaws with these reports:
https://docs.google.com/document/d/1-2soDLPWbvUQNpubrDmUE6B1lrK1VlNJWNHrrpt8UM8/edit# |
@sstead how sure are you that these problems are all new / due to this change? I am not at all across this, just wondering if your excellent issue detection skills have ever been applied to these reports before? |
Yes there’s a very good chance these are prexisting, this isn’t a report I test often. Should we log the other issues for later PRs? I can test more narrowly if that’s what’s needed.
…________________________________
From: Kirsten Larsen <[email protected]>
Sent: Wednesday, August 8, 2018 2:51:16 PM
To: openfoodfoundation/openfoodnetwork
Cc: Sally; Mention
Subject: Re: [openfoodfoundation/openfoodnetwork] 2014 refactor variant count on hand (#2413)
@sstead<https://github.com/sstead> how sure are you that these problems are all new / due to this change? I am not at all across this, just wondering if your excellent issue detection skills have ever been applied to these reports before?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2413 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKVzsJjqGZjJKS82RVo2aoaKv9qbnT93ks5uOm5EgaJpZM4U60-M>.
|
@sstead best way to tell if these are existing is to test on production, yes? And if you find them then log them as separate bugs 😃 |
I would be very surprised if those issues are caused by my code change. I only changed the This report is much older than the new inventory feature. It probably does make sense to rename it now. Maybe stock report? Anyway, to proceed with the Spree upgrade, I just want the report to perform as well as before. Changing the report and fixing it are other issues. |
Our added scope is not used anywhere and conflicts with the Spree upgrade. #2014
This change could impact the performance of the report. But therefore it takes VariantOverrides into consideration. The old code ignored the distributor for this filter. It also ignored the `on_demand` flag.
Testing notes
Broader issues spotted while testing are logged in this issue - https://github.com/openfoodfoundation/openfoodnetwork/issues/2529 https://docs.google.com/document/d/1-2soDLPWbvUQNpubrDmUE6B1lrK1VlNJWNHrrpt8UM8/edit# |
What? Why?
Part of #2014.
This prepares the inventory report and maybe more for the Spree upgrade. It also fixes a bug in filtering stocked variants and removes some unused code.
What should we test?
Release notes
Fixed bug in inventory report which ignored the distributor or on-demand setting for stock calculation. This may slow down the inventory report generation.
How is this related to the Spree upgrade?
This refactors some code to be compatible with Spree 2.0.