add /matches endpoint ad return match information in tickets and /item endpoints

This commit is contained in:
j3d1 2024-11-21 00:58:14 +01:00
parent aaa11c3b60
commit 797ea3ae12
12 changed files with 339 additions and 61 deletions

View file

@ -1,5 +1,6 @@
from django.core.files.base import ContentFile
from django.db import models, IntegrityError
from itertools import groupby
from django.db import models
from django_softdelete.models import SoftDeleteModel, SoftDeleteManager
@ -26,6 +27,13 @@ class Item(SoftDeleteModel):
created_at = models.DateTimeField(null=True, auto_now_add=True)
updated_at = models.DateTimeField(blank=True, null=True)
@property
def related_issues(self):
groups = groupby(self.issue_relation_changes.all(), lambda rel: rel.issue_thread.id)
return [sorted(v, key=lambda r: r.timestamp)[0].issue_thread for k, v in groups]
objects = ItemManager()
all_objects = models.Manager()