mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-07 05:40:26 -06:00
Add index for Grouping.grouping_key (and project)
This commit is contained in:
16
issues/migrations/0014_alter_grouping_unique_together.py
Normal file
16
issues/migrations/0014_alter_grouping_unique_together.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("projects", "0011_fill_stored_event_count"),
|
||||
("issues", "0013_fix_issue_stored_event_counts"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name="grouping",
|
||||
unique_together={("project", "grouping_key")},
|
||||
),
|
||||
]
|
||||
@@ -198,8 +198,8 @@ class Grouping(models.Model):
|
||||
"projects.Project", blank=False, null=True, on_delete=models.SET_NULL) # SET_NULL: cleanup 'later'
|
||||
|
||||
# NOTE: I don't want to have any principled maximum on the grouping key, nor do I want to prematurely optimize the
|
||||
# lookup. If lookups are slow, we _could_ examine whether manually hashing these values and matching on the hash
|
||||
# helps.
|
||||
# lookup. If lookups are slow (even with an index), we _could_ examine whether manually hashing these values and
|
||||
# matching on the hash helps.
|
||||
grouping_key = models.TextField(blank=False, null=False)
|
||||
|
||||
issue = models.ForeignKey("Issue", blank=False, null=True, on_delete=models.SET_NULL) # SET_NULL: cleanup 'later'
|
||||
@@ -207,6 +207,13 @@ class Grouping(models.Model):
|
||||
def __str__(self):
|
||||
return self.grouping_key
|
||||
|
||||
class Meta:
|
||||
unique_together = [
|
||||
# principled: grouping _key_ is a _key_ for a reason (within a project). This also implies the main way of
|
||||
# looking up groupings has an appropriate index.
|
||||
("project", "grouping_key"),
|
||||
]
|
||||
|
||||
|
||||
def format_unmute_reason(unmute_metadata):
|
||||
if "mute_until" in unmute_metadata:
|
||||
|
||||
Reference in New Issue
Block a user