-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Create plans and tiers tables #467
Changes from 3 commits
d90351b
2767d12
606857e
b132006
ba51c68
33f51ff
2af3938
0ded145
ec02329
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -997,3 +997,50 @@ def save(self, *args, **kwargs): | |||||||||||||
id=self.id | ||||||||||||||
).update(is_active=False) | ||||||||||||||
return super().save(*args, **kwargs) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class BillingRate(models.TextChoices): | ||||||||||||||
MONTHLY = "monthly" | ||||||||||||||
YEARLY = "yearly" | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class Plans(BaseModel): | ||||||||||||||
tier = models.ForeignKey( | ||||||||||||||
"Tiers", on_delete=models.CASCADE, related_name="plans", db_index=True | ||||||||||||||
) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I removed the index, seems unnecessary for a small table, but up to you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed with Nora, probably don't need an index here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, tbh i always like to use indexes you never know how big the table will grow to be |
||||||||||||||
base_unit_price = models.IntegerField(default=0) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this one should always have a value, assuming blank=True means nullable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank true means it can be null in the DB but it can't be optional in a form There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it makes sense if we are ever updating free plans There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, |
||||||||||||||
benefits = ArrayField(models.TextField(), blank=True, default=list) | ||||||||||||||
billing_rate = models.TextField( | ||||||||||||||
choices=BillingRate.choices, | ||||||||||||||
null=True, | ||||||||||||||
blank=True, | ||||||||||||||
) | ||||||||||||||
is_active = models.BooleanField(default=True) | ||||||||||||||
marketing_name = models.CharField(max_length=255) | ||||||||||||||
max_seats = models.IntegerField(null=True, blank=True) | ||||||||||||||
monthly_uploads_limit = models.IntegerField(null=True, blank=True) | ||||||||||||||
paid_plan = models.BooleanField(default=False) | ||||||||||||||
plan_name = models.CharField(max_length=255, unique=True) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a thought here, should we just call this "name?" since it's already on the plan 🤔 |
||||||||||||||
|
||||||||||||||
class Meta: | ||||||||||||||
db_table = "plans" | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this do? :O There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's just a clean way of naming the database |
||||||||||||||
app_label = CODECOV_AUTH_APP_LABEL | ||||||||||||||
|
||||||||||||||
def __str__(self): | ||||||||||||||
return self.plan_name | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class Tiers(BaseModel): | ||||||||||||||
tier_name = models.CharField(max_length=255, unique=True) | ||||||||||||||
bundle_analysis = models.BooleanField(default=False) | ||||||||||||||
test_analytics = models.BooleanField(default=False) | ||||||||||||||
flaky_test_detection = models.BooleanField(default=False) | ||||||||||||||
patch_coverage = models.BooleanField(default=False) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be project coverage right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes good catch |
||||||||||||||
private_repo_support = models.BooleanField(default=False) | ||||||||||||||
|
||||||||||||||
class Meta: | ||||||||||||||
db_table = "tiers" | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prob not needed for a new table unless there's naming overlap with another table |
||||||||||||||
app_label = CODECOV_AUTH_APP_LABEL | ||||||||||||||
|
||||||||||||||
def __str__(self): | ||||||||||||||
return self.tier_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use
PlanBillingRate
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be annually instead of yearly as well I think https://github.com/codecov/gazebo/blob/113a97f9e6a40ab9162576599308e123a25626aa/src/shared/utils/billing.ts#L29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know we have it but i think we can't use enum.Enum directly in the choices argument of a Django model field, we'll have to do
[(tag.value, tag.name) for tag in PlanBillingRate]
which is not very clean.I'll update to annually