mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Project quota: pick up on settings-changes
This commit is contained in:
16
projects/migrations/0015_project_quota_exceeded_reason.py
Normal file
16
projects/migrations/0015_project_quota_exceeded_reason.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("projects", "0014_alter_projectmembership_project"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="project",
|
||||
name="quota_exceeded_reason",
|
||||
field=models.CharField(default="null", max_length=255),
|
||||
),
|
||||
]
|
||||
22
projects/migrations/0016_reset_quota_exceeded_until.py
Normal file
22
projects/migrations/0016_reset_quota_exceeded_until.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def reset_quota_exceeded_until(apps, schema_editor):
|
||||
# Reset the quota_exceeded_until field for all Project records. Since `quota_exceeded_until` is an optimization
|
||||
# (saves checkes) doing this is never "incorrect" (at the cost of one ingestion per project).
|
||||
# We do it here to ensure that there are no records with a value of `quota_exceeded_until` but without a value for
|
||||
# the new field `quota_exceeded_reason`. (from now on, the 2 will always be set together, but the field is new)
|
||||
|
||||
Project = apps.get_model("projects", "Project")
|
||||
Project.objects.filter(quota_exceeded_until__isnull=False).update(quota_exceeded_until=None)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("projects", "0015_project_quota_exceeded_reason"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(reset_quota_exceeded_until, migrations.RunPython.noop),
|
||||
]
|
||||
@@ -114,6 +114,7 @@ class Project(models.Model):
|
||||
|
||||
# ingestion/digestion quota
|
||||
quota_exceeded_until = models.DateTimeField(null=True, blank=True)
|
||||
quota_exceeded_reason = models.CharField(max_length=255, null=False, default="null")
|
||||
next_quota_check = models.PositiveIntegerField(null=False, default=0)
|
||||
|
||||
# retention
|
||||
|
||||
Reference in New Issue
Block a user