Order numbers #28
Replies: 6 comments 12 replies
-
Yo' I do agree on this. But the worst case scenario that we want to avoid at all cost, is that 2 codes orders are almost the same, and can be confused with each. |
Beta Was this translation helpful? Give feedback.
-
i don't understand why we need a prefix - suffix. Is it no enough to keep the 2 first digit sequential, and the two last random (or edit a list with all the possibility and the ones we don't want close each other). |
Beta Was this translation helpful? Give feedback.
-
I think it's a very good improvement, we always thought that the actual generated codes can lead to a lot of confusion. |
Beta Was this translation helpful? Give feedback.
-
Sorry to come here and stop the party 🚓 In the current state of things, order numbers need to be unique. Currently, the algorithm is very simple: it takes the "real" ID from the database (it's a number), and changes its base (we count in base 10, it gets converted to base 32). The kind of things you are proposing, to be implemented, need a much more complicated system with a database sequence, need to handle race conditions (need to make sure that 2 orders at the same minute/second don't share the same number) The prefix is a bad idea IMHO, because:
Regarding number of digits and possible combinations, I'm always careful when I hear "this will never happen", "it's big enough". The separator is however a good idea. To generate less predictable order numbers, we could switch to something like sqids (we are already using hashids from the same author). This will generate alphanumeric strings that do not follow each other, that we can split with hyphens, and show the last 3 for example to users. The probability of same last X digits for the same day is low enough. |
Beta Was this translation helpful? Give feedback.
-
Here is an example using Sqids to encode IDs from 50000 to 75000. It encodes the IDs as a 9 symbols string, and splits it in pieces of 3.
|
Beta Was this translation helpful? Give feedback.
-
Goal: have a code format that is non-sequential in order to minimize the possibility to confusing orders like E31D and E31E, because the sequentiality makes us only use the last two digit/letters. However, we also need something both simple for messengers and dispatch and customers, but big enough to allow for codes not to repeat over multiple months.
I am proposing:
Cooperatives pick a 2 letter prefix for each restaurant in a field in the restaurant configuration page. Ex: Eatyjet = EJ
Codes would be six digits/letters long with a - in the middle and format [prefix][prefix][number]-[num/letter][num/letter][num/letter]
Example:
EJ4-X3F
EJ2-SP9
DP7-U7C
By doing this we have 4 digits/letters that give us hundreds of thousands of options. Even a very high volume cooperative would have them rotate over large timespans like half a year which facilitates customer service and dispatch. On the backend, coopcycle can user the other ID we have that is a long unique number for database management.
Additionally, messengers will typically use the last three letter/digits for day to day use, but the prefix allows group orders to function correctly when we implement those (one order would have the same 4 digits/letters, but the pickup from EatyJet would be EJ prefix, pickup from dottorpizza with DP prefix)
Thoughts?
coopcycle/coopcycle-web#3770
Beta Was this translation helpful? Give feedback.
All reactions