Implement bookkeeping of events_at

(I didn't think the effects on regressions through, but this will at least
manifest itself because you cannot mark an issue as "fixed in" a release
in which it occurs. It will also show up once we start displaying "events_at"
in the UI, which should be "soon")
This commit is contained in:
Klaas van Schelven
2024-04-16 12:58:51 +02:00
parent d89e3d4dd5
commit 5ae0a8227f
2 changed files with 21 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ from .views import BaseIngestAPIView
class IngestViewTestCase(DjangoTestCase):
# this TestCase started out as focussed on alert-sending, but has grown beyond that. Sometimes simply by extending
# existing tests. This is not a problem in itself, but may be slightly confusing if you don't realize that.
def setUp(self):
# the existence of loud/quiet reflect that parts of this test focusses on alert-sending
@@ -54,6 +56,8 @@ class IngestViewTestCase(DjangoTestCase):
self.assertTrue(send_new_issue_alert.delay.called)
self.assertFalse(send_regression_alert.delay.called)
self.assertFalse(send_unmute_alert.delay.called)
self.assertEquals(1, Issue.objects.count())
self.assertEquals("\n", Issue.objects.get().events_at)
self.assertEquals(1, TurningPoint.objects.count())
self.assertEquals(TurningPointKind.FIRST_SEEN, TurningPoint.objects.first().kind)
@@ -227,6 +231,20 @@ class IngestViewTestCase(DjangoTestCase):
request,
)
def test_ingest_view_stores_events_at(self):
request = self.request_factory.post("/api/1/store/")
event_data = create_event_data()
event_data["release"] = "1.0"
BaseIngestAPIView().process_event(
event_data,
self.loud_project,
request,
)
self.assertEquals(1, Issue.objects.count())
self.assertEquals("1.0\n", Issue.objects.get().events_at)
class TimeZoneTesCase(DjangoTestCase):
"""This class contains some tests that formalize my understanding of how Django works; they are not strictly tests

View File

@@ -178,7 +178,7 @@ class BaseIngestAPIView(APIView):
# multiple events with the same event_id "don't happen" (i.e. are the result of badly misbehaving clients)
raise ValidationError("Event already exists", code="event_already_exists")
create_release_if_needed(ingested_event.project, event.release, event)
release = create_release_if_needed(ingested_event.project, event.release, event)
if issue_created:
TurningPoint.objects.create(
@@ -225,7 +225,8 @@ class BaseIngestAPIView(APIView):
issue_pc = get_pc_registry().by_issue[issue.id]
issue_pc.inc(ingested_event.timestamp, counted_entity=event)
# TODO bookkeeping of events_at goes here.
if release.version + "\n" not in issue.events_at:
issue.events_at += release.version + "\n"
issue.save()