korbit-ai[bot] commented on code in PR #32235:
URL: https://github.com/apache/superset/pull/32235#discussion_r1952864079
##########
superset/migrations/shared/native_filters.py:
##########
@@ -49,7 +48,7 @@
:see: convert_filter_scopes
"""
- shortid = ShortId()
+ short_id = f"{shortid()}"[:9]
Review Comment:
@hainenber, understanding that you would like to maintain the 9-character
limit for ID's, one possible solution could incorporate a mix of timestamp and
random generation to ensure uniqueness. Here's a simple method making use of
Python's datetime and random libraries:
```python
import datetime
import random
import string
def generate_unique_id():
timestamp = datetime.datetime.now().strftime('%H%M%S%f')
random_string = ''.join(random.choices(string.ascii_letters +
string.digits, k=3))
unique_id = timestamp + random_string
return unique_id
```
Please note that even this is not perfect and does come with an
infinitesimally small chance of ID collision, especially under high-throughput
conditions, due to its dependence on accurate timekeeping and random string
generation. You may want to implement an additional verification step to check
for any ID collisions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]