Skip to content

Commit

Permalink
Fix user experiment override handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfies committed Jun 12, 2024
1 parent fb3d3ad commit 98b65f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions discord/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def __contains__(self, item: Guild, /) -> bool:

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::
Expand Down Expand Up @@ -648,7 +648,7 @@ def result_for(self, guild: Snowflake, /) -> int:

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
-----------
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -778,7 +778,7 @@ def __init__(self, *, state: ConnectionState, data: AssignmentPayload):
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
Expand Down Expand Up @@ -817,7 +817,7 @@ def bucket(self) -> int:
""":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:
Expand Down

0 comments on commit 98b65f4

Please sign in to comment.