diff --git a/apps/backend/src/modules/activity-logs/activity-log.controller.ts b/apps/backend/src/modules/activity-logs/activity-log.controller.ts index f002c440..ff837744 100644 --- a/apps/backend/src/modules/activity-logs/activity-log.controller.ts +++ b/apps/backend/src/modules/activity-logs/activity-log.controller.ts @@ -168,8 +168,17 @@ class ActivityLogController extends BaseController { query: ActivityLogQueryParameters; }>, ): Promise { + const { contributorName, endDate, projectId, startDate } = options.query; + + const query = { + endDate, + startDate, + ...(contributorName ? { contributorName } : {}), + ...(projectId ? { projectId: Number(projectId) } : {}), + }; + return { - payload: await this.activityLogService.findAll(options.query), + payload: await this.activityLogService.findAll(query), status: HTTPCode.OK, }; } diff --git a/apps/backend/src/modules/activity-logs/activity-log.service.ts b/apps/backend/src/modules/activity-logs/activity-log.service.ts index a603cb3f..f9f31c87 100644 --- a/apps/backend/src/modules/activity-logs/activity-log.service.ts +++ b/apps/backend/src/modules/activity-logs/activity-log.service.ts @@ -165,7 +165,7 @@ class ActivityLogService implements Service { const allContributors = await this.contributorService.findAll({ contributorName, - projectId: projectId ? Number(projectId) : undefined, + projectId, }); const dateRange = getDateRange(formattedStartDate, formattedEndDate); diff --git a/apps/frontend/src/modules/activity/activity-logs-api.ts b/apps/frontend/src/modules/activity/activity-logs-api.ts index 00442930..b583a2eb 100644 --- a/apps/frontend/src/modules/activity/activity-logs-api.ts +++ b/apps/frontend/src/modules/activity/activity-logs-api.ts @@ -29,7 +29,7 @@ class ActivityLogApi extends BaseHTTPApi { ...(contributorName ? { contributorName } : {}), endDate, startDate, - ...(projectId ? { projectId } : {}), + ...(projectId ? { projectId: String(projectId) } : {}), }; const response = await this.load( diff --git a/apps/frontend/src/modules/projects/slices/actions.ts b/apps/frontend/src/modules/projects/slices/actions.ts index da9818ae..cb14e719 100644 --- a/apps/frontend/src/modules/projects/slices/actions.ts +++ b/apps/frontend/src/modules/projects/slices/actions.ts @@ -106,7 +106,7 @@ const loadAllContributorsByProjectId = createAsyncThunk< void dispatch( loadAllContributorsActivityByProjectId({ endDate, - projectId: String(projectId), + projectId, startDate, }), ); diff --git a/apps/frontend/src/pages/analytics/analytics.tsx b/apps/frontend/src/pages/analytics/analytics.tsx index cac0d2c4..166be284 100644 --- a/apps/frontend/src/pages/analytics/analytics.tsx +++ b/apps/frontend/src/pages/analytics/analytics.tsx @@ -94,7 +94,7 @@ const Analytics = (): JSX.Element => { activityLogActions.loadAll({ contributorName: search, endDate: formattedEndDate, - projectId: projectId?.toString() ?? undefined, + projectId: projectId ?? undefined, startDate: formattedStartDate, }), ); diff --git a/packages/shared/src/modules/activity-logs/libs/types/activity-log-query-parameters.type.ts b/packages/shared/src/modules/activity-logs/libs/types/activity-log-query-parameters.type.ts index c72a2536..7b8341f8 100644 --- a/packages/shared/src/modules/activity-logs/libs/types/activity-log-query-parameters.type.ts +++ b/packages/shared/src/modules/activity-logs/libs/types/activity-log-query-parameters.type.ts @@ -1,7 +1,7 @@ type ActivityLogQueryParameters = { contributorName?: string | undefined; endDate: string; - projectId?: string | undefined; + projectId?: number | undefined; startDate: string; }; diff --git a/packages/shared/src/modules/activity-logs/libs/validation-schemas/activity-log-get.validation-schema.ts b/packages/shared/src/modules/activity-logs/libs/validation-schemas/activity-log-get.validation-schema.ts index c6b89dd1..797067ba 100644 --- a/packages/shared/src/modules/activity-logs/libs/validation-schemas/activity-log-get.validation-schema.ts +++ b/packages/shared/src/modules/activity-logs/libs/validation-schemas/activity-log-get.validation-schema.ts @@ -7,7 +7,6 @@ const activityLogGet: z.ZodType = z.object({ endDate: z.string({ required_error: ActivityLogValidationMessage.END_DATE_REQUIRED, }), - projectId: z.string().optional(), startDate: z.string({ required_error: ActivityLogValidationMessage.START_DATE_REQUIRED, }),