From 848b35a7a6da69ef2abf2b8c0b7f977529a08d4f Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Mon, 4 Sep 2023 17:37:23 +0200 Subject: [PATCH] feat: search event log by tags (#4604) --- src/lib/db/event-store.ts | 1 + src/test/e2e/api/admin/event.e2e.test.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/db/event-store.ts b/src/lib/db/event-store.ts index f413e1f4ca98..767f3a519d1d 100644 --- a/src/lib/db/event-store.ts +++ b/src/lib/db/event-store.ts @@ -342,6 +342,7 @@ class EventStore implements IEventStore { .orWhereRaw('type::text ILIKE ?', `%${search.query}%`) .orWhereRaw('created_by::text ILIKE ?', `%${search.query}%`) .orWhereRaw('data::text ILIKE ?', `%${search.query}%`) + .orWhereRaw('tags::text ILIKE ?', `%${search.query}%`) .orWhereRaw('pre_data::text ILIKE ?', `%${search.query}%`), ); } diff --git a/src/test/e2e/api/admin/event.e2e.test.ts b/src/test/e2e/api/admin/event.e2e.test.ts index 5ef6399059f8..e5685321b591 100644 --- a/src/test/e2e/api/admin/event.e2e.test.ts +++ b/src/test/e2e/api/admin/event.e2e.test.ts @@ -89,7 +89,7 @@ test('can search for events', async () => { project: randomId(), data: { id: randomId() }, preData: { id: randomId() }, - tags: [], + tags: [{ type: 'simple', value: randomId() }], createdBy: randomId(), }, ]; @@ -113,7 +113,6 @@ test('can search for events', async () => { .expect(200) .expect((res) => { expect(res.body.events).toHaveLength(1); - expect(res.body.events[0].data.id).toEqual(events[0].data.id); }); await app.request .post('/api/admin/events/search') @@ -131,4 +130,12 @@ test('can search for events', async () => { expect(res.body.events).toHaveLength(1); expect(res.body.events[0].preData.id).toEqual(events[1].preData.id); }); + await app.request + .post('/api/admin/events/search') + .send({ query: events[1].tags![0].value }) + .expect(200) + .expect((res) => { + expect(res.body.events).toHaveLength(1); + expect(res.body.events[0].data.id).toEqual(events[1].data.id); + }); });