mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-06 05:10:15 -06:00
Tags: on event details page show calculated tags
(not just the explicitly provided ones)
This commit is contained in:
@@ -5,6 +5,7 @@ import uuid
|
||||
from django.db import models
|
||||
from django.db.utils import IntegrityError
|
||||
from django.db.models import Min, Max
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
from projects.models import Project
|
||||
from compat.timestamp import parse_timestamp
|
||||
@@ -286,3 +287,9 @@ class Event(models.Model):
|
||||
|
||||
def has_next(self):
|
||||
return self.digest_order < self.get_digest_order_bounds()[1]
|
||||
|
||||
@cached_property
|
||||
def get_tags(self):
|
||||
return list(
|
||||
self.tags.all().select_related("value", "value__key").order_by("value__key__key")
|
||||
)
|
||||
|
||||
@@ -58,14 +58,14 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if parsed_data.tags %}
|
||||
{% if event.tags %}
|
||||
<h1 id="tags" class="text-2xl font-bold mt-4">Tags</h1>
|
||||
|
||||
<div class="mb-6">
|
||||
{% for key, value in parsed_data.tags|items %}
|
||||
{% for tag in event.get_tags %}
|
||||
<div class="flex {% if forloop.first %}border-slate-300 border-t-2{% endif %}">
|
||||
<div class="w-1/4 {% if not forloop.last %}border-b-2 border-dotted border-slate-300{% endif %}">{{ key }}</div>
|
||||
<div class="w-3/4 {% if not forloop.last %} border-b-2 border-dotted border-slate-300{% endif %} font-mono">{{ value }}</div>
|
||||
<div class="w-1/4 {% if not forloop.last %}border-b-2 border-dotted border-slate-300{% endif %}">{{ tag.value.key.key }}</div>
|
||||
<div class="w-3/4 {% if not forloop.last %} border-b-2 border-dotted border-slate-300{% endif %} font-mono">{{ tag.value.value }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 4.2.19 on 2025-03-03 09:42
|
||||
# Generated by Django 4.2.19 on 2025-03-03 10:28
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
@@ -9,9 +9,9 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("issues", "0010_issue_list_indexes"),
|
||||
("events", "0019_event_storage_backend"),
|
||||
("projects", "0011_fill_stored_event_count"),
|
||||
("events", "0019_event_storage_backend"),
|
||||
("issues", "0010_issue_list_indexes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@@ -164,6 +164,12 @@ class Migration(migrations.Migration):
|
||||
name="issuetag",
|
||||
unique_together={("value", "issue")},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="eventtag",
|
||||
index=models.Index(
|
||||
fields=["event", "value"], name="tags_eventt_event_i_86e88e_idx"
|
||||
),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name="eventtag",
|
||||
unique_together={("value", "event")},
|
||||
|
||||
@@ -72,6 +72,9 @@ class EventTag(models.Model):
|
||||
|
||||
class Meta:
|
||||
unique_together = ('value', 'event')
|
||||
indexes = [
|
||||
models.Index(fields=['event', 'value']), # make lookups by event (for details page) faster
|
||||
]
|
||||
|
||||
|
||||
# class GroupingTag is not needed (not even for future-proofing); it would only be needed if you'd want to "unmerge"
|
||||
|
||||
Reference in New Issue
Block a user