Skip to content

Commit

Permalink
add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-codecov committed Feb 21, 2024
1 parent 5568c02 commit 7203d8f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion shared/django_apps/rollouts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.db import models


# TODO: move to utils
def default_random_salt():
chars = []
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand All @@ -13,6 +14,11 @@ def default_random_salt():


class FeatureFlag(models.Model):
"""
Represents a feature and its rollout parameters (see shared/rollouts/__init__.py). A
default salt will be created if one is not provided.
"""

name = models.CharField(max_length=200, primary_key=True)
proportion = models.DecimalField(default=0, decimal_places=3, max_digits=4)
salt = models.CharField(max_length=10000, default=default_random_salt)
Expand All @@ -26,7 +32,15 @@ class Meta:


class FeatureFlagVariant(models.Model):
name = models.CharField(max_length=200, primary_key=True)
"""
Represents a variant of the feature being rolled out and the proportion of
the test population it should be rolled out to (see shared/rollouts/__init__.py).
The proportion should be a float between 0 and 1. A proportion of 0.5 means 50% of
the test population should receive this variant. Ensure that for any `FeatureFlag`,
the proportions of the corresponding `FeatureFlagVariant`s sum to 1.
"""

name = models.CharField(max_length=200, primary_key=True)
feature_flag = models.ForeignKey(
"FeatureFlag", on_delete=models.CASCADE, related_name="variants"
)
Expand Down

0 comments on commit 7203d8f

Please sign in to comment.