diff --git a/posthog/demo/matrix/matrix.py b/posthog/demo/matrix/matrix.py index 7e35d8535ac1e..5f43bc1027cb4 100644 --- a/posthog/demo/matrix/matrix.py +++ b/posthog/demo/matrix/matrix.py @@ -183,7 +183,7 @@ def roll_uuidt(self, at_timestamp: Optional[dt.datetime] = None) -> UUIDT: def roll_uuid_v7(self, at_timestamp: Optional[dt.datetime] = None) -> uuid.UUID: if at_timestamp is None: at_timestamp = self.simulation_time - return uuid7(int(at_timestamp.timestamp() * 1000), seeded_random=self.random) + return uuid7(int(at_timestamp.timestamp() * 1000), random=self.random) class Matrix(ABC): diff --git a/posthog/models/utils.py b/posthog/models/utils.py index 9572214dfc8c8..f16bd09984e13 100644 --- a/posthog/models/utils.py +++ b/posthog/models/utils.py @@ -96,9 +96,7 @@ def is_valid_uuid(cls, candidate: Any) -> bool: # Delete this when we can use the version from the stdlib directly, see https://github.com/python/cpython/issues/102461 -def uuid7( - unix_ms_time: Optional[Union[int, str]] = None, random_component: Optional[Union["Random", int]] = None -) -> uuid.UUID: +def uuid7(unix_ms_time: Optional[Union[int, str]] = None, random: Optional[Union["Random", int]] = None) -> uuid.UUID: # timestamp part unix_ms_time_int: int if isinstance(unix_ms_time, str): @@ -113,14 +111,14 @@ def uuid7( unix_ms_time_int = unix_ms_time # random part - if isinstance(random_component, int): + if isinstance(random, int): # use the integer directly as the random component - rand_a = random_component & 0x0FFF - rand_b = random_component >> 12 & 0x03FFFFFFFFFFFFFFF - elif random_component is not None: + rand_a = random & 0x0FFF + rand_b = random >> 12 & 0x03FFFFFFFFFFFFFFF + elif random is not None: # use the provided random generator - rand_a = random_component.getrandbits(12) - rand_b = random_component.getrandbits(56) + rand_a = random.getrandbits(12) + rand_b = random.getrandbits(56) else: # use the system random generator rand_bytes = int.from_bytes(secrets.token_bytes(10), byteorder="little")