Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support actionType filter in auditlogs #2634

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop index if exists "auditLogAction_actionType";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create index "auditLogAction_actionType" on "auditLogAction"("actionType");

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const action: MultiSelectFilterConfig = {
},
apiFilterRenderer({ value, include }: MultiSelectFilterValue): any[] {
const filter = {
action: { in: value },
actionType: { in: value },
};
return [
(include ? filter : { not: filter }),
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/modules/lf/config/audit-logs/filters/action/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ const options: SelectFilterOptionGroup[] = [
options: [
{
label: 'Profiles merged',
value: 'contributors-merged',
value: 'members-merge',
},
{
label: 'Profiles unmerged',
value: 'contributors-unmerged',
value: 'members-unmerge',
},
{
label: 'Profile identities updated',
value: 'contributor-identities-updated',
value: 'members-edit-identities',
},
{
label: 'Profile work experience updated',
value: 'contributor-work-experience-updated',
value: 'members-edit-organizations',
},
{
label: 'Profile affiliation updated',
value: 'contributor-affiliation-updated',
value: 'members-edit-manual-affiliation',
},
{
label: 'Profile updated',
value: 'contributor-profile-updated',
value: 'members-edit-profile',
},
{
label: 'Profile created',
value: 'contributor-created',
value: 'members-create',
},
],
},
Expand All @@ -47,15 +47,15 @@ const options: SelectFilterOptionGroup[] = [
},
{
label: 'Organization identities updated',
value: 'organization-identities-updated',
value: 'organizations-edit-identities',
},
{
label: 'Organization profile updated',
value: 'organization-profile-updated',
value: 'organizations-edit-profile',
},
{
label: 'Organization created',
value: 'organization-created',
value: 'organizations-create',
},
],
},
Expand All @@ -64,11 +64,11 @@ const options: SelectFilterOptionGroup[] = [
options: [
{
label: 'Integration connected',
value: 'integration-connected',
value: 'integrations-connect',
},
{
label: 'Integration re-connected',
value: 'integration-re-connected',
value: 'integrations-reconnect',
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/modules/lf/config/audit-logs/filters/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { FilterConfig } from '@/shared/modules/filters/types/FilterConfig';
import user from './user/config';
import entityId from './entityId/config';
import action from './action/config';

export const auditLogsFilters: Record<string, FilterConfig> = {
entityId,
user,
action,
};
8 changes: 8 additions & 0 deletions services/libs/data-access-layer/src/audit_logs/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export async function addAuditAction(
}

export async function queryAuditLogs(qx: QueryExecutor, { limit, offset, filter }) {
let actionType: string[] = undefined
let where = ''

if (filter?.entityId) {
Expand All @@ -126,6 +127,12 @@ export async function queryAuditLogs(qx: QueryExecutor, { limit, offset, filter
where += ` AND a."userId" = $(userId)`
}

if (filter?.actionType || filter?.not?.actionType) {
const condition = filter.not ? 'NOT IN' : 'IN'
where += ` AND a."actionType" ${condition} ($(actionType:csv))`
actionType = filter.not ? filter.not.actionType.in : filter.actionType.in
}

const result = await qx.select(
`
SELECT
Expand All @@ -148,6 +155,7 @@ export async function queryAuditLogs(qx: QueryExecutor, { limit, offset, filter
offset,
userId: filter?.userId,
entityId: filter?.entityId,
actionType,
},
)

Expand Down
Loading