Project quota: pick up on settings-changes

This commit is contained in:
Klaas van Schelven
2026-01-07 14:02:43 +01:00
parent 7d550708f1
commit 7b7cd66dfb
4 changed files with 84 additions and 13 deletions

View 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),
),
]

View 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),
]

View File

@@ -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