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

Refactor GroupOrderArticle updates #579

Open
wvengen opened this issue Oct 15, 2018 · 1 comment
Open

Refactor GroupOrderArticle updates #579

wvengen opened this issue Oct 15, 2018 · 1 comment
Labels
tech debt technical debt

Comments

@wvengen
Copy link
Member

wvengen commented Oct 15, 2018

There are several places where GroupOrderArticles are created and/or updated. This happens in different ways. It would be healthy to consolidate that, if possible.

Let's investigate a bit and then see what makes sense.

  • Member ordering just calls the group order's save_group_order_articles. Here all order articles are iterated, and at the end the group order totals are saved.
  • Balancing: add & remove ordergroup for order article: this template using goa controller. Here only the result it set, as computation of who gets what is already done, and the order article's result doesn't change anymore.
  • API /api/v1/group_order_articles (in PR API-4: ordering #573) does something similar as member ordering, but then per group order article.
@wvengen wvengen mentioned this issue Oct 15, 2018
6 tasks
@wvengen wvengen added the tech debt technical debt label Oct 15, 2018
@wvengen
Copy link
Member Author

wvengen commented Jan 22, 2021

#573 (comment)

I looked it it again, and the moment when OrderArticle#update_results! and GroupOrder#update_price! are called depends on the action that is taken: if multiple products are updated in a group order, GroupOrder#update_price! only needs to be called once at the end (not each time a GroupOrderArticle is modified) - this happens in the regular member ordering screens. And when an OrderArticle is updated among multiple group orders, #update_results! only needs to be called once at the end too (we don't do this currently, as far as I know, but it could be possible).

Perhaps ideally I'd have some kind of system that queues OrderArticle#update_results! and GroupOrder#update_price! for the speciic order article and group order when a GroupOrderArticle is changed, and then at the end of the transaction, all of these queued updates are performed once. We don't have such a system currently. So I think the place for these calls is in the code that requests the GroupOrderArticle updates, which in this case is the controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt technical debt
Projects
None yet
Development

No branches or pull requests

1 participant