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

Option to directly save stock in stockable model table #12

Open
hfoletto opened this issue Nov 16, 2021 · 0 comments
Open

Option to directly save stock in stockable model table #12

hfoletto opened this issue Nov 16, 2021 · 0 comments

Comments

@hfoletto
Copy link

The stock method of the HasStock trait returns the current stock value if no date is given.
It gets the value by summing all the stock mutations the stockable model has.

It works without issues, however if there are thousands of stock mutations and it's required to have a page that shows hundreads of products and their stock, such SQL query might be quite expensive.

I think it would be useful to have an option to save the current stock after a stock mutation, so when calling the stock method without a date, it just returns the value, without the need to sum everything.

Would a PR for this feature be welcome?

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

No branches or pull requests

1 participant