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

Added LazyCustomerLoader for OrderType of SyliusAdminApiBundle #9050

Merged
merged 3 commits into from
Dec 18, 2019

Conversation

jdeveloper
Copy link
Contributor

Q A
Branch? 1.0.5
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #8776, mentioned in #8815
License MIT

return $self->customerRepository->findOneBy(['email' => $email]);
};

return array_map($mapEmailToCustomer, $values);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not sure if taking this approach or add a findCustomersWithEmails method in the CustomerRepository.

I finally opted this approach since it was created specifically to just load the customer by the email submited.

@pamil pamil added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). Potential Bug Potential bugs or bugfixes, that needs to be reproduced. labels Dec 27, 2017
@pamil pamil added this to the 1.0 milestone Dec 27, 2017
@Chrysweel
Copy link
Contributor

@pamil @jdeveloper this pull request will accepted in some time ?

We have the same problem...

@pamil pamil removed this from the 1.0 milestone Apr 27, 2018
@ping86
Copy link
Contributor

ping86 commented Jul 5, 2018

Is planned solve this issue, or is fixed in v1.2?

Thanks.

@pamil
Copy link
Contributor

pamil commented Jul 6, 2018

I'm on it, sorry for the delay!

@pamil pamil self-assigned this Jul 6, 2018
@pamil pamil self-requested a review July 6, 2018 09:51
@jdeveloper
Copy link
Contributor Author

Hello, I am asking once again for the state of this PR since I think it's a clear improve when there are a lot of users in the database.

I have no problem to change implementation if you think it 's not a valid one.

Thanks in advance.

@jdeveloper
Copy link
Contributor Author

@pamil Sorry for asking this one more time

Is this PR to be considered? I once again need to creat by REST a cart and it just creates a timeout with a large customer table.

I have no regards to take some time to adapt, improve the code

@jdeveloper
Copy link
Contributor Author

Hi @pamil

Sorry for asking once again but we have a database with more then 200 k customers and we want to use the sylius API without deppending on SyliusShopApiPlugin. It is imposible to create a cart without this PR.

It would be nice to review this PR, I think it is also a benefit for other developers. If we have to make changes on this PR just comment them and we will work on them.

@lchrusciel
Copy link
Member

Hey @jdeveloper,

It took too long to provide you some feedback here. We all are humans, and sometimes we tend to forget or miss something. When you asked for a review, we (as a core team) had too much on our heads.

I will ping @CoderMaggie to add this issue to our sprints. Therefore someone should take a look over it in the nearest sprint (if it only will fit into backlog). Please, ping me one more time if it won't be resolved during the next month.

Thank you for your patience.

@jdeveloper
Copy link
Contributor Author

Hey @lchrusciel,

Thanks for replying. Don't worry, we understand that we are all humans and with such a huge project like Sylius, things can quickly go out of control. We appreciate your reply to an old issue.

As always, if we have to work in some issue around this PR, just ping me.

Thank you for your attention.

@jdeveloper
Copy link
Contributor Author

Hi @lchrusciel

I just wonder about the state of this PR. As you said to ping you if I got sign on this PR in a month here I am just pinging you to look if we can solve this together. I think it can benefit a lot of people and shops that have a lot of customers and want to integrate through REST API.

Have a nice time.

@jdeveloper jdeveloper requested a review from a team as a code owner December 18, 2019 08:39
@lchrusciel lchrusciel force-pushed the optimize_create_cart_api branch 3 times, most recently from 57dfd94 to 48eb318 Compare December 18, 2019 08:50
@lchrusciel lchrusciel changed the base branch from master to 1.5 December 18, 2019 08:51
@lchrusciel
Copy link
Member

lchrusciel commented Dec 18, 2019

As a part of the work over this PR, I've decided to make some profiling. @jdeveloper proposition reduced the time of execution by 62%, but this change may be much greater for a bigger set of data.
image

You can check the complete profile here.
Data was collected on my local machine, with a set of 10k customers in DB.

The current solution assumes that customers are not loaded to choice type, which makes sense because it is used only in the Admin API Context. To make this choice type usable for the twig based templates, we should introduce Autocomplete Form Type. On the other hand, this form type wouldn't be used anywhere in current Sylius implementation. It is tested already with cart creation endpoint in Admin API.

Therefore, it could be improved in the future, but I think that the current solution is good to go.

I'm also considering writing an ADR for this feature, not to lose track of it. (/cc @Sylius/core-team)

Also, thank you @jdeveloper for the contribution and sorry for a long time for merging it. I've decided to append your work, I hope you don't mind.

@pamil pamil merged commit 1d2c83d into Sylius:1.5 Dec 18, 2019
@pamil
Copy link
Contributor

pamil commented Dec 18, 2019

Thanks, @jdeveloper! 🥇

@Chrysweel
Copy link
Contributor

Chrysweel commented Dec 18, 2019

giphy

Congrats @jdeveloper ! Congrats Sylius Team !

@p-carrillo
Copy link

señorordena

@jdeveloper
Copy link
Contributor Author

WoW I'm so happy to see this merged. Thanks a lot. It's a great pleasure being able to contribute.

@pamil
Copy link
Contributor

pamil commented Dec 18, 2019

Hope things will go more smoothly in the future, thanks for your patience 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). Potential Bug Potential bugs or bugfixes, that needs to be reproduced.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants