Making order number generator issues more visible to stores #5502
RyanofWoods
started this conversation in
New Features or Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When an Order number is generated, if a collision occurs, it will check how many orders there are in the database. If over half of the possible number possibilities are already taken, then the order length is temporarily increased by 1 to avoid collisions.
https://github.com/solidusio/solidus/blob/main/core/app/models/spree/order/number_generator.rb#L38
This isn't optimal as counting the order records where there are millions takes multiple seconds. This used to be worse problem before as we would calculate the order count for each collision, until I fixed it:
#4722
Looking at the bigger picture, this solution hides the problem from stores and puts performance cost on the user. We are also assuming that stores are okay with their order length being changed. What if they have integrations not expecting this?
I am wondering whether we should just have an health check instead for this (could be on the admin), and remove the counting logic from the generator. If we do this, we could add the health check first, and put the generator count logic behind a config, so that stores have a chance to check their generator health before changing generator logic.
WDYT?
Beta Was this translation helpful? Give feedback.
All reactions