Browse Source

Fix user experiment override handling

pull/10109/head
dolfies 12 months ago
parent
commit
9f782b608f
  1. 14
      discord/experiment.py
  2. 6
      discord/types/experiment.py

14
discord/experiment.py

@ -353,7 +353,7 @@ class ExperimentPopulation:
def bucket_for(self, guild: Guild, _result: Optional[int] = None, /) -> int:
"""Returns the assigned experiment bucket within a population for a guild.
Defaults to none (-1) if the guild is not in the population.
Defaults to None (-1) if the guild is not in the population.
.. note::
@ -648,7 +648,7 @@ class GuildExperiment:
def bucket_for(self, guild: Guild, /) -> int:
"""Returns the assigned experiment bucket for a guild.
Defaults to none (-1) if the guild is not in the experiment.
Defaults to None (-1) if the guild is not in the experiment.
Parameters
-----------
@ -747,10 +747,10 @@ class UserExperiment:
The current revision of the experiment rollout.
assignment: :class:`int`
The assigned bucket for the user.
override: :class:`int`
The overriden bucket for the user, takes precedence over :attr:`assignment`.
override: :class:`bool`
Whether the user has an explicit bucket override.
population: :class:`int`
The internal population group for the user.
The internal population group for the user, or None (-1) if manually overridden.
aa_mode: :class:`bool`
Whether the experiment is in A/A mode.
trigger_debugging:
@ -778,7 +778,7 @@ class UserExperiment:
self.hash: int = hash
self.revision: int = revision
self.assignment: int = bucket
self.override: int = override
self.override: bool = override == 0 # this is fucking weird
self.population: int = population
self._result: int = hash_result
self.aa_mode: bool = aa_mode == 1
@ -817,7 +817,7 @@ class UserExperiment:
""":class:`int`: The assigned bucket for the user."""
if self.aa_mode:
return -1
return self.override if self.override != -1 else self.population
return self.assignment
@property
def result(self) -> int:

6
discord/types/experiment.py

@ -58,7 +58,9 @@ Filters = List[
Tuple[Literal[3013771838], Tuple[Tuple[Literal[3013771838], List[int]]]], # IDs
Tuple[Literal[4148745523], Tuple[Tuple[Literal[4148745523], List[int]]]], # HUB_TYPE
Tuple[Literal[188952590], Tuple[Tuple[Literal[188952590], bool]]], # VANITY_URL
Tuple[Literal[2294888943], Tuple[Tuple[Literal[2690752156], int], Tuple[Literal[1982804121], int]]], # RANGE_BY_HASH
Tuple[
Literal[2294888943], Tuple[Tuple[Literal[2690752156], int], Tuple[Literal[1982804121], int]]
], # RANGE_BY_HASH
]
]
@ -84,7 +86,7 @@ UserExperiment = Tuple[
int, # hash
int, # revision
int, # bucket
int, # override
Literal[-1, 0], # override
int, # population
int, # hash_result
Literal[0, 1], # aa_mode

Loading…
Cancel
Save