Skip to content

Commit

Permalink
Merge branch 'main' into 504-feat-add-project-select-to-contributors-…
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
GvoFor committed Sep 25, 2024
2 parents 7818fa2 + 61eeb62 commit c118158
Show file tree
Hide file tree
Showing 29 changed files with 260 additions and 52 deletions.
10 changes: 5 additions & 5 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
".": "1.54.0",
"apps/backend": "1.33.3",
"apps/frontend": "1.50.0",
"packages/shared": "1.31.1",
"scripts/analytics": "1.7.0"
".": "1.56.0",
"apps/backend": "1.35.0",
"apps/frontend": "1.52.0",
"packages/shared": "1.33.0",
"scripts/analytics": "1.8.0"
}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [1.56.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/v1.55.0...v1.56.0) (2024-09-25)


### Features

* add search field to analytics page gf-352 ([#444](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/444)) ([71dcfb1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/71dcfb15462b289bad70d90f65875bea40bbc560))
* upgrade the visibility of the project's options button on the project detail page gf-508 ([#514](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/514)) ([1d7d6f1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/1d7d6f1f8ed86321fe2b7231c0424d06a5772daa))


### Bug Fixes

* reload contributors on split gf-519 ([#525](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/525)) ([f766ce8](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/f766ce8145a202626ad154753dc01e1af5ee29f4))

## [1.55.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/v1.54.0...v1.55.0) (2024-09-25)


### Features

* add an ability to mark contributors as hidden gf-346 ([#400](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/400)) ([6143e4c](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/6143e4cb851e28de4080230e5e80e0665f65f41f))


### Bug Fixes

* adjusted loader and placeholder to render properly when loading gf-515 ([#520](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/520)) ([f94c6b6](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/f94c6b614d4e2a2f37f41a62d7cb2d5d1594d513))

## [1.54.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/v1.53.1...v1.54.0) (2024-09-25)


Expand Down
14 changes: 14 additions & 0 deletions apps/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.35.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.34.0...backend-v1.35.0) (2024-09-25)


### Features

* add search field to analytics page gf-352 ([#444](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/444)) ([71dcfb1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/71dcfb15462b289bad70d90f65875bea40bbc560))

## [1.34.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.33.3...backend-v1.34.0) (2024-09-25)


### Features

* add an ability to mark contributors as hidden gf-346 ([#400](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/400)) ([6143e4c](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/6143e4cb851e28de4080230e5e80e0665f65f41f))

## [1.33.3](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.33.2...backend-v1.33.3) (2024-09-25)


Expand Down
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@git-fit/backend",
"type": "module",
"version": "1.33.3",
"version": "1.35.0",
"engines": {
"node": "20.x.x",
"npm": "10.x.x"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ActivityLogRepository implements Repository {
}

public async findAll({
contributorName,
endDate,
projectId,
startDate,
Expand All @@ -56,6 +57,10 @@ class ActivityLogRepository implements Repository {
.whereBetween("activity_logs.date", [startDate, endDate])
.orderBy("date");

if (contributorName) {
query.whereILike("gitEmail:contributor.name", `%${contributorName}%`);
}

if (projectId) {
query.where("project_id", projectId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class ActivityLogService implements Service {
}

public async findAll({
contributorName,
endDate,
projectId,
startDate,
Expand All @@ -152,6 +153,7 @@ class ActivityLogService implements Service {
);

const activityLogsEntities = await this.activityLogRepository.findAll({
contributorName,
endDate: formattedEndDate,
projectId,
startDate: formattedStartDate,
Expand All @@ -162,6 +164,7 @@ class ActivityLogService implements Service {
);

const allContributors = await this.contributorService.findAll({
contributorName,
projectId: projectId ? Number(projectId) : undefined,
});

Expand Down Expand Up @@ -201,8 +204,8 @@ class ActivityLogService implements Service {
commitsNumber: commitsArray,
contributor: {
hiddenAt: null,
id: contributorId ?? "",
name: contributorName ?? "",
id: contributorId as string,
name: contributorName as string,
},
};
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ class ContributorController extends BaseController {
query: ContributorGetAllRequestDto;
}>,
): Promise<APIHandlerResponse> {
const { hasHidden, page, pageSize, projectId } = options.query;
const { contributorName, hasHidden, page, pageSize, projectId } =
options.query;

const query = {
...(contributorName ? { contributorName } : {}),
...(hasHidden ? { hasHidden: Boolean(hasHidden) } : {}),
...(page ? { page: Number(page) } : {}),
...(pageSize ? { pageSize: Number(pageSize) } : {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ContributorRepository implements Repository {
}

public async findAll({
contributorName,
hasHidden = false,
page,
pageSize,
Expand Down Expand Up @@ -88,6 +89,10 @@ class ContributorRepository implements Repository {
query.whereNull("contributors.hiddenAt");
}

if (contributorName) {
query.whereILike("contributors.name", `%${contributorName}%`);
}

if (projectId) {
query.havingRaw("?? = ANY(ARRAY_AGG(projects.id))", projectId);
}
Expand Down
25 changes: 25 additions & 0 deletions apps/frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [1.52.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/frontend-v1.51.0...frontend-v1.52.0) (2024-09-25)


### Features

* add search field to analytics page gf-352 ([#444](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/444)) ([71dcfb1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/71dcfb15462b289bad70d90f65875bea40bbc560))
* upgrade the visibility of the project's options button on the project detail page gf-508 ([#514](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/514)) ([1d7d6f1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/1d7d6f1f8ed86321fe2b7231c0424d06a5772daa))


### Bug Fixes

* reload contributors on split gf-519 ([#525](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/525)) ([f766ce8](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/f766ce8145a202626ad154753dc01e1af5ee29f4))

## [1.51.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/frontend-v1.50.0...frontend-v1.51.0) (2024-09-25)


### Features

* add an ability to mark contributors as hidden gf-346 ([#400](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/400)) ([6143e4c](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/6143e4cb851e28de4080230e5e80e0665f65f41f))


### Bug Fixes

* adjusted loader and placeholder to render properly when loading gf-515 ([#520](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/520)) ([f94c6b6](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/f94c6b614d4e2a2f37f41a62d7cb2d5d1594d513))

## [1.50.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/frontend-v1.49.1...frontend-v1.50.0) (2024-09-25)


Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@git-fit/frontend",
"private": true,
"version": "1.50.0",
"version": "1.52.0",
"type": "module",
"engines": {
"node": "20.x.x",
Expand Down
5 changes: 5 additions & 0 deletions apps/frontend/src/libs/components/menu/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { type ComponentProps } from "react";

import { IconButton, Popover } from "~/libs/components/components.js";

import styles from "./styles.module.css";

type Properties = {
buttonVariant?: ComponentProps<typeof IconButton>["variant"];
children: React.ReactNode;
isOpened: boolean;
onClose: () => void;
onOpen: () => void;
};

const Menu = ({
buttonVariant = "primary",
children,
isOpened,
onClose,
Expand All @@ -29,6 +33,7 @@ const Menu = ({
iconName="ellipsis"
label="options"
onClick={isOpened ? onClose : onOpen}
variant={buttonVariant}
/>
</Popover>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/modules/activity/activity-logs-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class ActivityLogApi extends BaseHTTPApi {
public async getAll(
query: ActivityLogQueryParameters,
): Promise<ActivityLogGetAllAnalyticsResponseDto> {
const { endDate, projectId, startDate } = query;
const { contributorName, endDate, projectId, startDate } = query;

const queryToSend = {
...(contributorName ? { contributorName } : {}),
endDate,
startDate,
...(projectId ? { projectId } : {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,7 @@ const { actions, name, reducer } = createSlice({
builder.addCase(split.pending, (state) => {
state.splitContributorsStatus = DataStatus.PENDING;
});
builder.addCase(split.fulfilled, (state, action) => {
const { id: splittingContributorId } = action.meta.arg;
const { payload: newContributor } = action;

state.contributors = state.contributors.map((contributor) => {
if (contributor.id !== splittingContributorId) {
return contributor;
}

const [splitEmail] = newContributor.gitEmails;

return {
...contributor,
gitEmails: contributor.gitEmails.filter(
({ id }) => id !== splitEmail?.id,
),
};
});

state.contributors = [newContributor, ...state.contributors];

builder.addCase(split.fulfilled, (state) => {
state.splitContributorsStatus = DataStatus.FULFILLED;
});
builder.addCase(split.rejected, (state) => {
Expand Down
27 changes: 24 additions & 3 deletions apps/frontend/src/pages/analytics/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ import {
useCallback,
useEffect,
useFormWatch,
useSearch,
} from "~/libs/hooks/hooks.js";
import { actions as activityLogActions } from "~/modules/activity/activity.js";

import { AnalyticsTable } from "./libs/components/components.js";
import {
AnalyticsContributorsSearch,
AnalyticsTable,
} from "./libs/components/components.js";
import {
ANALYTICS_DATE_MAX_RANGE,
ANALYTICS_DEFAULT_DATE_RANGE,
Expand All @@ -33,6 +37,8 @@ const Analytics = (): JSX.Element => {
ANALYTICS_LOOKBACK_DAYS_COUNT,
);

const { onSearch, search } = useSearch();

const { activityLogs, dataStatus, projects } = useAppSelector(
({ activityLogs }) => activityLogs,
);
Expand All @@ -41,16 +47,24 @@ const Analytics = (): JSX.Element => {
void dispatch(activityLogActions.loadAllProjects());
}, [dispatch]);

const { control, handleSubmit, isDirty } = useAppForm({
const { control, errors, handleSubmit, isDirty } = useAppForm({
defaultValues: {
dateRange: [
subtractDays(todayDate, ANALYTICS_DEFAULT_DATE_RANGE),
todayDate,
] as [Date, Date],
project: null,
search,
},
});

const handleSearchChange = useCallback(
(value: string) => {
onSearch(value);
},
[onSearch],
);

const dateRangeValue = useFormWatch({ control, name: "dateRange" });
const projectValue = useFormWatch({ control, name: "project" });

Expand All @@ -64,13 +78,14 @@ const Analytics = (): JSX.Element => {

void dispatch(
activityLogActions.loadAll({
contributorName: search,
endDate: formattedEndDate,
projectId: projectId ?? undefined,
startDate: formattedStartDate,
}),
);
},
[dispatch],
[dispatch, search],
);

useEffect(() => {
Expand Down Expand Up @@ -102,6 +117,12 @@ const Analytics = (): JSX.Element => {
<h1 className={styles["title"]}>Analytics</h1>
<section>
<form className={styles["filters-form"]} onSubmit={handleFormSubmit}>
<AnalyticsContributorsSearch
control={control}
errors={errors}
name="search"
onChange={handleSearchChange}
/>
<div className={styles["select-wrapper"]}>
<Select
control={control}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
type Control,
type FieldErrors,
type FieldPath,
type FieldValues,
} from "react-hook-form";

import { Search } from "~/libs/components/components.js";

import styles from "./styles.module.css";

type Properties<T extends FieldValues> = {
control: Control<T, null>;
errors: FieldErrors<T>;
name: FieldPath<T>;
onChange: (search: string) => void;
};

const AnalyticsContributorsSearch = <T extends FieldValues>({
control,
errors,
name,
onChange,
}: Properties<T>): JSX.Element => {
return (
<div className={styles["search-container"]}>
<Search
control={control}
errors={errors}
isLabelHidden
label="Contributors search"
name={name}
onChange={onChange}
placeholder="Enter name"
/>
</div>
);
};

export { AnalyticsContributorsSearch };
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.search-container {
width: 300px;
background-color: var(--color-background-secondary);
}
Loading

0 comments on commit c118158

Please sign in to comment.