Skip to content

Commit

Permalink
refactor: make projectId be a number in ActivityLogQueryParameters ty…
Browse files Browse the repository at this point in the history
…pe gf-504
  • Loading branch information
GvoFor committed Sep 26, 2024
1 parent 3e14e24 commit daf3498
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,17 @@ class ActivityLogController extends BaseController {
query: ActivityLogQueryParameters;
}>,
): Promise<APIHandlerResponse> {
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,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/modules/activity/activity-logs-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ActivityLogApi extends BaseHTTPApi {
...(contributorName ? { contributorName } : {}),
endDate,
startDate,
...(projectId ? { projectId } : {}),
...(projectId ? { projectId: String(projectId) } : {}),
};

const response = await this.load(
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/modules/projects/slices/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const loadAllContributorsByProjectId = createAsyncThunk<
void dispatch(
loadAllContributorsActivityByProjectId({
endDate,
projectId: String(projectId),
projectId,
startDate,
}),
);
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/analytics/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Analytics = (): JSX.Element => {
activityLogActions.loadAll({
contributorName: search,
endDate: formattedEndDate,
projectId: projectId?.toString() ?? undefined,
projectId: projectId ?? undefined,
startDate: formattedStartDate,
}),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type ActivityLogQueryParameters = {
contributorName?: string | undefined;
endDate: string;
projectId?: string | undefined;
projectId?: number | undefined;
startDate: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const activityLogGet: z.ZodType<ActivityLogQueryParameters> = z.object({
endDate: z.string({
required_error: ActivityLogValidationMessage.END_DATE_REQUIRED,
}),
projectId: z.string().optional(),
startDate: z.string({
required_error: ActivityLogValidationMessage.START_DATE_REQUIRED,
}),
Expand Down

0 comments on commit daf3498

Please sign in to comment.