Skip to content
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
2 changes: 2 additions & 0 deletions apps/backend/src/libs/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ export {
formatDate,
getDateRange,
getDifferenceInDays,
getEndOfDay,
getStartOfDay,
subtractDays,
} from "@git-fit/shared";
23 changes: 19 additions & 4 deletions apps/backend/src/modules/activity-logs/activity-log.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { EMPTY_LENGTH } from "~/libs/constants/constants.js";
import { ExceptionMessage } from "~/libs/enums/enums.js";
import { formatDate, getDateRange } from "~/libs/helpers/helpers.js";
import {
formatDate,
getDateRange,
getEndOfDay,
getStartOfDay,
} from "~/libs/helpers/helpers.js";
import { HTTPCode } from "~/libs/modules/http/http.js";
import { type Service } from "~/libs/types/types.js";
import { type ContributorService } from "~/modules/contributors/contributors.js";
Expand Down Expand Up @@ -136,10 +141,20 @@ class ActivityLogService implements Service {
projectId,
startDate,
}: ActivityLogQueryParameters): Promise<ActivityLogGetAllAnalyticsResponseDto> {
const formattedStartDate = formatDate(
getStartOfDay(new Date(startDate)),
"yyyy-MM-dd",
);

const formattedEndDate = formatDate(
getEndOfDay(new Date(endDate)),
"yyyy-MM-dd",
);

const activityLogsEntities = await this.activityLogRepository.findAll({
endDate,
endDate: formattedEndDate,
projectId,
startDate,
startDate: formattedStartDate,
});

const activityLogs = activityLogsEntities.items.map((item) =>
Expand All @@ -150,7 +165,7 @@ class ActivityLogService implements Service {
? this.contributorService.findAllByProjectId(Number(projectId))
: this.contributorService.findAllWithoutPagination());

const dateRange = getDateRange(startDate, endDate);
const dateRange = getDateRange(formattedStartDate, formattedEndDate);

const INITIAL_COMMITS_NUMBER = 0;
const contributorMap: Record<string, number[]> = {};
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/libs/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
formatRelativeTime,
getDateRange,
getDifferenceInDays,
getEndOfDay,
getRelativeDate,
getStartOfDay,
initDebounce,
Expand Down
14 changes: 11 additions & 3 deletions apps/frontend/src/pages/analytics/analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { DateInput, PageLayout, Select } from "~/libs/components/components.js";
import { DataStatus } from "~/libs/enums/enums.js";
import { subtractDays } from "~/libs/helpers/helpers.js";
import {
formatDate,
getEndOfDay,
getStartOfDay,
subtractDays,
} from "~/libs/helpers/helpers.js";
import {
useAppDispatch,
useAppForm,
Expand Down Expand Up @@ -50,8 +55,11 @@ const Analytics = (): JSX.Element => {

const handleLoadLogs = useCallback(
([startDate, endDate]: [Date, Date], projectId?: null | string) => {
const formattedStartDate = startDate.toISOString();
const formattedEndDate = endDate.toISOString();
const formattedStartDate = formatDate(
getStartOfDay(startDate),
"yyyy-MM-dd",
);
const formattedEndDate = formatDate(getEndOfDay(endDate), "yyyy-MM-dd");

void dispatch(
activityLogActions.loadAll({
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export {
formatRelativeTime,
getDateRange,
getDifferenceInDays,
getEndOfDay,
getRelativeDate,
getStartOfDay,
initDebounce,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { endOfDay } from "date-fns";

const getEndOfDay = (date: Date): Date => {
return endOfDay(new Date(date));
};

export { getEndOfDay };
1 change: 1 addition & 0 deletions packages/shared/src/libs/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { formatDate } from "./format-date/format-date.helper.js";
export { formatRelativeTime } from "./format-relative-time/format-relative-time.helper.js";
export { getDateRange } from "./get-date-range/get-date-range.helper.js";
export { getDifferenceInDays } from "./get-difference-in-days/get-difference-in-days.helper.js";
export { getEndOfDay } from "./get-end-of-day/get-end-of-day.helper.js";
export { getRelativeDate } from "./get-relative-date/get-relative-date.helper.js";
export { getStartOfDay } from "./get-start-of-day/get-start-of-day.helper.js";
export { initDebounce } from "./init-debounce/init-debounce.helper.js";
Expand Down