mirror of
https://github.com/bugsink/bugsink.git
synced 2026-05-08 07:50:04 -05:00
Issue.fixed_at and Issue.events_at: bracketless
for easier qs-based updates (later/soon)
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('issues', '0010_issue_unmute_after'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='issue',
|
||||||
|
name='events_at',
|
||||||
|
field=models.TextField(default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='issue',
|
||||||
|
name='fixed_at',
|
||||||
|
field=models.TextField(default=''),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def become_bracketless(apps, schema_editor):
|
||||||
|
Issue = apps.get_model('issues', 'Issue')
|
||||||
|
|
||||||
|
for issue in Issue.objects.all():
|
||||||
|
issue.fixed_at = issue.fixed_at[1:-1]
|
||||||
|
issue.events_at = issue.events_at[1:-1]
|
||||||
|
issue.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('issues', '0011_alter_issue_events_at_alter_issue_fixed_at'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(become_bracketless)
|
||||||
|
]
|
||||||
+7
-5
@@ -8,6 +8,8 @@ from django.db import models
|
|||||||
from bugsink.volume_based_condition import VolumeBasedCondition
|
from bugsink.volume_based_condition import VolumeBasedCondition
|
||||||
from alerts.tasks import send_unmute_alert
|
from alerts.tasks import send_unmute_alert
|
||||||
|
|
||||||
|
from .utils import parse_bracketless, serialize_bracketless
|
||||||
|
|
||||||
|
|
||||||
class IncongruentStateException(Exception):
|
class IncongruentStateException(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -30,8 +32,8 @@ class Issue(models.Model):
|
|||||||
# it also simply means: it was "marked as resolved" after the last regression (if any)
|
# it also simply means: it was "marked as resolved" after the last regression (if any)
|
||||||
is_resolved = models.BooleanField(default=False)
|
is_resolved = models.BooleanField(default=False)
|
||||||
is_resolved_by_next_release = models.BooleanField(default=False)
|
is_resolved_by_next_release = models.BooleanField(default=False)
|
||||||
fixed_at = models.TextField(blank=False, null=False, default='[]')
|
fixed_at = models.TextField(blank=False, null=False, default='')
|
||||||
events_at = models.TextField(blank=False, null=False, default='[]')
|
events_at = models.TextField(blank=False, null=False, default='')
|
||||||
|
|
||||||
# fields related to muting:
|
# fields related to muting:
|
||||||
is_muted = models.BooleanField(default=False)
|
is_muted = models.BooleanField(default=False)
|
||||||
@@ -72,17 +74,17 @@ class Issue(models.Model):
|
|||||||
return main_exception.get("type", "none") + ": " + main_exception.get("value", "none")
|
return main_exception.get("type", "none") + ": " + main_exception.get("value", "none")
|
||||||
|
|
||||||
def get_fixed_at(self):
|
def get_fixed_at(self):
|
||||||
return json.loads(self.fixed_at)
|
return parse_bracketless(self.fixed_at)
|
||||||
|
|
||||||
def get_events_at(self):
|
def get_events_at(self):
|
||||||
return json.loads(self.events_at)
|
return parse_bracketless(self.events_at)
|
||||||
|
|
||||||
def add_fixed_at(self, release_version):
|
def add_fixed_at(self, release_version):
|
||||||
# release_version: str
|
# release_version: str
|
||||||
fixed_at = self.get_fixed_at()
|
fixed_at = self.get_fixed_at()
|
||||||
if release_version not in fixed_at:
|
if release_version not in fixed_at:
|
||||||
fixed_at.append(release_version)
|
fixed_at.append(release_version)
|
||||||
self.fixed_at = json.dumps(fixed_at)
|
self.fixed_at = serialize_bracketless(fixed_at)
|
||||||
|
|
||||||
def occurs_in_last_release(self):
|
def occurs_in_last_release(self):
|
||||||
return False # TODO actually implement (and then: implement in a performant manner)
|
return False # TODO actually implement (and then: implement in a performant manner)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
@@ -40,3 +41,11 @@ def get_hash_for_data(data):
|
|||||||
# NOTE: issue_grouper should be renamed to what it _is_ (hash is accidental, 'grouper', or 'key' maybe?
|
# NOTE: issue_grouper should be renamed to what it _is_ (hash is accidental, 'grouper', or 'key' maybe?
|
||||||
issue_grouper = get_issue_grouper_for_data(data)
|
issue_grouper = get_issue_grouper_for_data(data)
|
||||||
return hashlib.md5(issue_grouper.encode()).hexdigest()
|
return hashlib.md5(issue_grouper.encode()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def parse_bracketless(s):
|
||||||
|
return json.loads(f"[{s}]")
|
||||||
|
|
||||||
|
|
||||||
|
def serialize_bracketless(l):
|
||||||
|
return json.dumps(l)[1:-1]
|
||||||
|
|||||||
Reference in New Issue
Block a user