refactor: Refactor audit logs count to support filtering (#4113)

This commit is contained in:
Bruno Quaresma
2022-09-19 14:08:25 -03:00
committed by GitHub
parent 6f82ad09c8
commit adad347902
9 changed files with 164 additions and 13 deletions

View File

@ -37,7 +37,20 @@ OFFSET
SELECT
COUNT(*) as count
FROM
audit_logs;
audit_logs
WHERE
-- Filter resource_type
CASE
WHEN @resource_type :: text != '' THEN
resource_type = @resource_type :: resource_type
ELSE true
END
-- Filter action
AND CASE
WHEN @action :: text != '' THEN
action = @action :: audit_action
ELSE true
END;
-- name: InsertAuditLog :one
INSERT INTO