From 2a49742986bc79fbe4022d0e4527b3d2d18ab0ac Mon Sep 17 00:00:00 2001 From: Yeganathan S Date: Thu, 3 Oct 2024 18:18:06 +0530 Subject: [PATCH 1/4] support actionType filter in auditlogs --- .../audit-logs/filters/action/config.ts | 2 +- .../audit-logs/filters/action/options.ts | 24 +++++++++---------- .../lf/config/audit-logs/filters/main.ts | 2 ++ .../data-access-layer/src/audit_logs/repo.ts | 8 +++++++ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/frontend/src/modules/lf/config/audit-logs/filters/action/config.ts b/frontend/src/modules/lf/config/audit-logs/filters/action/config.ts index 4d93bd79fc..9e4c44ac6a 100644 --- a/frontend/src/modules/lf/config/audit-logs/filters/action/config.ts +++ b/frontend/src/modules/lf/config/audit-logs/filters/action/config.ts @@ -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 }), diff --git a/frontend/src/modules/lf/config/audit-logs/filters/action/options.ts b/frontend/src/modules/lf/config/audit-logs/filters/action/options.ts index 685cf7947d..85a318a848 100644 --- a/frontend/src/modules/lf/config/audit-logs/filters/action/options.ts +++ b/frontend/src/modules/lf/config/audit-logs/filters/action/options.ts @@ -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', }, ], }, @@ -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', }, ], }, @@ -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', }, ], }, diff --git a/frontend/src/modules/lf/config/audit-logs/filters/main.ts b/frontend/src/modules/lf/config/audit-logs/filters/main.ts index a110e090c3..d937338c03 100644 --- a/frontend/src/modules/lf/config/audit-logs/filters/main.ts +++ b/frontend/src/modules/lf/config/audit-logs/filters/main.ts @@ -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 = { entityId, user, + action, }; diff --git a/services/libs/data-access-layer/src/audit_logs/repo.ts b/services/libs/data-access-layer/src/audit_logs/repo.ts index 75c919921f..26c3101458 100644 --- a/services/libs/data-access-layer/src/audit_logs/repo.ts +++ b/services/libs/data-access-layer/src/audit_logs/repo.ts @@ -106,6 +106,7 @@ export async function addAuditAction( } export async function queryAuditLogs(qx: QueryExecutor, { limit, offset, filter }) { + let actionType: string[] = undefined let where = '' if (filter?.entityId) { @@ -122,6 +123,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 @@ -144,6 +151,7 @@ export async function queryAuditLogs(qx: QueryExecutor, { limit, offset, filter offset, userId: filter?.userId, entityId: filter?.entityId, + actionType, }, ) From 425e2d22ec41533cd4e0ee58daa98e83534911d8 Mon Sep 17 00:00:00 2001 From: garrrikkotua Date: Mon, 7 Oct 2024 11:24:39 +0400 Subject: [PATCH 2/4] descrease PRs per page --- .../src/integrations/github/api/graphql/pullRequests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/libs/integrations/src/integrations/github/api/graphql/pullRequests.ts b/services/libs/integrations/src/integrations/github/api/graphql/pullRequests.ts index 3ca8ef9bd2..5a8da81b86 100644 --- a/services/libs/integrations/src/integrations/github/api/graphql/pullRequests.ts +++ b/services/libs/integrations/src/integrations/github/api/graphql/pullRequests.ts @@ -5,7 +5,7 @@ import BaseQuery from './baseQuery' class PullRequestsQuery extends BaseQuery { repo: Repo - constructor(repo: Repo, githubToken: string, perPage = 20) { + constructor(repo: Repo, githubToken: string, perPage = 5) { const pullRequestsQuery = `{ repository(owner: "${repo.owner}", name: "${repo.name}") { pullRequests(last: ${perPage}, \${beforeCursor}) { From d27b665442f4a75b840b77739a085a6b58ffd52a Mon Sep 17 00:00:00 2001 From: Yeganathan S Date: Wed, 9 Oct 2024 17:14:27 +0530 Subject: [PATCH 3/4] add db index --- .../database/migrations/U1728473951__auditLogsFilterIndex.sql | 1 + .../database/migrations/V1728473951__auditLogsFilterIndex.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql create mode 100644 backend/src/database/migrations/V1728473951__auditLogsFilterIndex.sql diff --git a/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql b/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql new file mode 100644 index 0000000000..722e16a0f4 --- /dev/null +++ b/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql @@ -0,0 +1 @@ +DROP INDEX IF EXISTS "auditLogAction_actionType"; \ No newline at end of file diff --git a/backend/src/database/migrations/V1728473951__auditLogsFilterIndex.sql b/backend/src/database/migrations/V1728473951__auditLogsFilterIndex.sql new file mode 100644 index 0000000000..30252aa099 --- /dev/null +++ b/backend/src/database/migrations/V1728473951__auditLogsFilterIndex.sql @@ -0,0 +1,2 @@ +create index "auditLogAction_actionType" on "auditLogAction"("actionType"); + From a2f18a8da6b789fb51a982df73dca4c17fc66915 Mon Sep 17 00:00:00 2001 From: Yeganathan S Date: Wed, 9 Oct 2024 17:15:39 +0530 Subject: [PATCH 4/4] nitpick: sql in lowercae --- .../database/migrations/U1728473951__auditLogsFilterIndex.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql b/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql index 722e16a0f4..efe606201d 100644 --- a/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql +++ b/backend/src/database/migrations/U1728473951__auditLogsFilterIndex.sql @@ -1 +1 @@ -DROP INDEX IF EXISTS "auditLogAction_actionType"; \ No newline at end of file +drop index if exists "auditLogAction_actionType"; \ No newline at end of file