From adf24b24d43975e2033db8296ae07c4ca8bcce94 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 17 Mar 2024 20:02:57 +0530 Subject: [PATCH] perf: use base32 space for random names instead of base16 (#25497) --- frappe/model/naming.py | 30 ++++++++++++++++++++++++++---- frappe/tests/test_naming.py | 19 ++++++++++++++++++- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/frappe/model/naming.py b/frappe/model/naming.py index ab21fe0156..7dabb3d80d 100644 --- a/frappe/model/naming.py +++ b/frappe/model/naming.py @@ -1,6 +1,7 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE +import base64 import datetime import re import struct @@ -264,15 +265,36 @@ def make_autoname(key="", doctype="", doc="", *, ignore_validate=False): DE/09/01/00001 where 09 is the year, 01 is the month and 00001 is the series """ if key == "hash": - # Makeshift "ULID": first 4 chars are based on timestamp, other 8 are random - ts = hex(struct.unpack("