Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix query
  • Loading branch information
BrunoQuaresma committed Sep 16, 2022
commit 897562a54a86e28bc917546177575cb65c9ff75e
4 changes: 2 additions & 2 deletions coderd/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ func auditSearchQuery(query string) (database.GetAuditLogsOffsetParams, []coders
// other parsing.
parser := httpapi.NewQueryParamParser()
filter := database.GetAuditLogsOffsetParams{
ResourceType: database.ResourceType(parser.String(searchParams, "", "resource_type")),
Action: database.AuditAction(parser.String(searchParams, "", "action")),
ResourceType: parser.String(searchParams, "", "resource_type"),
Action: parser.String(searchParams, "", "action"),
}

return filter, parser.Errors
Expand Down
4 changes: 2 additions & 2 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2337,11 +2337,11 @@ func (q *fakeQuerier) GetAuditLogsOffset(ctx context.Context, arg database.GetAu
continue
}

if arg.Action != "" && !strings.Contains(string(alog.Action), string(arg.Action)) {
if arg.Action != "" && !strings.Contains(string(alog.Action), arg.Action) {
continue
}

if arg.ResourceType != "" && !strings.Contains(string(alog.ResourceType), string(arg.ResourceType)) {
if arg.ResourceType != "" && !strings.Contains(string(alog.ResourceType), arg.ResourceType) {
continue
}

Expand Down
16 changes: 8 additions & 8 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions coderd/database/queries/auditlogs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ LEFT JOIN
WHERE
-- Filter resource_type
CASE
WHEN @resource_type :: resource_type != '' THEN
resource_type = @resource_type
WHEN @resource_type :: text != '' THEN
resource_type = @resource_type :: resource_type
ELSE true
END
-- Filter action
AND CASE
WHEN @action :: audit_action != '' THEN
action = @action
WHEN @action :: text != '' THEN
action = @action :: audit_action
ELSE true
END
ORDER BY
Expand Down