Skip to content

[Backend] Update audit events to allow filtering by username

Jiaan Louw requested to merge 335016-add-filter-audit-events-by-username into master

What does this MR do and why?

This MR updates audit events on all levels (Instance, Group, Project) to allow for filtering by entity or author username to resolve #335016 (closed). It retains the ability to filter by user id to be backwards compatible with any audit event links users may have saved. This is part 1 containing the backend changes, the frontend MR which will add this in the UI is !73742 (merged).

Database

Original query

explain SELECT "audit_events".* FROM "audit_events" WHERE "audit_events"."entity_id" = 1

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/7190/commands/25408

Note: In our controller we limit searches to a maximum of 31 day date range. So real world queries run faster.

With additional username search

SELECT "users".* FROM "users" WHERE (LOWER("users"."username") IN (LOWER('root'))) LIMIT 1

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/7191/commands/25409

Screenshots or screen recordings

No visual changes.

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #335016 (closed)

Edited by Jiaan Louw

Merge request reports