Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…4-gitfit into 351-feat-adjust-project-permissions
  • Loading branch information
Anna Kasian committed Sep 24, 2024
2 parents 6d00f75 + a793d37 commit f274e3b
Show file tree
Hide file tree
Showing 53 changed files with 565 additions and 126 deletions.
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
".": "1.51.0",
"apps/backend": "1.32.0",
"apps/frontend": "1.47.0",
"packages/shared": "1.30.0",
".": "1.53.0",
"apps/backend": "1.33.1",
"apps/frontend": "1.49.0",
"packages/shared": "1.31.0",
"scripts/analytics": "1.7.0"
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [1.53.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/v1.52.0...v1.53.0) (2024-09-24)


### Features

* add Tooltip component and adjust gitEmail column gf-450 ([#497](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/497)) ([5583d7e](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/5583d7ebe22b01b9eff84b136ef7e8785b5a1521))


### Bug Fixes

* make sidebar width consistent gf-475 ([#500](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/500)) ([c3148b0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/c3148b0d638407fd629794e42c3b54bffdd1c7fa))
* user profile not deleted without "Manage User Access" permission gf-449 ([#478](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/478)) ([5e017f5](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/5e017f58640efbaca8ace6877e5c8a846b11ce62))

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


### Features

* add infinite scroll and pagination to notificationspopover gf-458 ([#490](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/490)) ([9daf38b](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/9daf38b8ab392357d17919a0a6507e884d5a52be))
* add projects select to analytics page gf-348 ([#470](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/470)) ([47d8620](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/47d8620dff09d6f21febd1cb74fa08fb53fd6fca))

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


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

## [1.33.1](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.33.0...backend-v1.33.1) (2024-09-24)


### Bug Fixes

* user profile not deleted without "Manage User Access" permission gf-449 ([#478](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/478)) ([5e017f5](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/5e017f58640efbaca8ace6877e5c8a846b11ce62))

## [1.33.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.32.0...backend-v1.33.0) (2024-09-24)


### Features

* add infinite scroll and pagination to notificationspopover gf-458 ([#490](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/490)) ([9daf38b](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/9daf38b8ab392357d17919a0a6507e884d5a52be))
* add projects select to analytics page gf-348 ([#470](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/issues/470)) ([47d8620](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/commit/47d8620dff09d6f21febd1cb74fa08fb53fd6fca))

## [1.32.0](https://github.com/BinaryStudioAcademy/bsa-2024-gitfit/compare/backend-v1.31.0...backend-v1.32.0) (2024-09-23)


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.32.0",
"version": "1.33.1",
"engines": {
"node": "20.x.x",
"npm": "10.x.x"
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/modules/notifications/libs/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export {
type NotificationBulkCreateResponseDto,
type NotificationCreateRequestDto,
type NotificationGetAllItemResponseDto,
type NotificationGetAllRequestDto,
type NotificationGetAllResponseDto,
type UserAuthResponseDto,
} from "@git-fit/shared";
46 changes: 37 additions & 9 deletions apps/backend/src/modules/notifications/notification.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { HTTPCode } from "~/libs/modules/http/http.js";
import { type Logger } from "~/libs/modules/logger/logger.js";

import { NotificationsApiPath } from "./libs/enums/enums.js";
import {
type NotificationGetAllRequestDto,
type UserAuthResponseDto,
} from "./libs/types/types.js";
import { type NotificationService } from "./notification.service.js";

/**
Expand Down Expand Up @@ -43,7 +47,12 @@ class NotificationController extends BaseController {
this.notificationService = notificationService;

this.addRoute({
handler: (options) => this.findAll(options),
handler: (options) =>
this.findAll(
options as APIHandlerOptions<{
query: NotificationGetAllRequestDto;
}>,
),
method: "GET",
path: NotificationsApiPath.ROOT,
});
Expand All @@ -53,7 +62,18 @@ class NotificationController extends BaseController {
* @swagger
* /notifications:
* get:
* description: Returns an array of notifications
* description: Returns an array of notifications with pagination
* parameters:
* - in: query
* name: page
* schema:
* type: integer
* description: The page number to retrieve
* - in: query
* name: pageSize
* schema:
* type: integer
* description: The number of items per page
* responses:
* 200:
* description: Successful operation
Expand All @@ -66,19 +86,27 @@ class NotificationController extends BaseController {
* type: array
* items:
* $ref: "#/components/schemas/Notification"
* totalItems:
* type: integer
* description: The total number of notifications
*/
private async findAll(
options: APIHandlerOptions,
): Promise<APIHandlerResponse> {
const { user } = options;

const typedUser = user as { id: number };
private async findAll({
query,
user,
}: APIHandlerOptions<{
query: NotificationGetAllRequestDto;
}>): Promise<APIHandlerResponse> {
const { page, pageSize } = query;

return {
payload: await this.notificationService.findAll(typedUser.id),
payload: await this.notificationService.findAll({
page,
pageSize,
userId: (user as UserAuthResponseDto).id,
}),
status: HTTPCode.OK,
};
}
}

export { NotificationController };
22 changes: 16 additions & 6 deletions apps/backend/src/modules/notifications/notification.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { SortType } from "~/libs/enums/enums.js";
import { type Repository } from "~/libs/types/types.js";
import {
type PaginationResponseDto,
type Repository,
} from "~/libs/types/types.js";

import { type NotificationGetAllRequestDto } from "./libs/types/types.js";
import { NotificationEntity } from "./notification.entity.js";
import { type NotificationModel } from "./notification.model.js";

Expand Down Expand Up @@ -56,19 +60,25 @@ class NotificationRepository implements Repository {
return Promise.resolve(null);
}

public async findAll(
userId: number,
): Promise<{ items: NotificationEntity[] }> {
const notifications = await this.notificationModel
public async findAll({
page,
pageSize,
userId,
}: NotificationGetAllRequestDto): Promise<
PaginationResponseDto<NotificationEntity>
> {
const { results, total } = await this.notificationModel
.query()
.where("receiverUserId", userId)
.orderBy("created_at", SortType.DESCENDING)
.page(page, pageSize)
.execute();

return {
items: notifications.map((notification) =>
items: results.map((notification) =>
NotificationEntity.initialize(notification),
),
totalItems: total,
};
}

Expand Down
10 changes: 7 additions & 3 deletions apps/backend/src/modules/notifications/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type NotificationBulkCreateResponseDto,
type NotificationCreateRequestDto,
type NotificationGetAllItemResponseDto,
type NotificationGetAllRequestDto,
type NotificationGetAllResponseDto,
} from "./libs/types/types.js";
import { NotificationEntity } from "./notification.entity.js";
Expand Down Expand Up @@ -60,11 +61,14 @@ class NotificationService implements Service {
return Promise.resolve(null);
}

public async findAll(userId: number): Promise<NotificationGetAllResponseDto> {
const result = await this.notificationRepository.findAll(userId);
public async findAll(
parameters: NotificationGetAllRequestDto,
): Promise<NotificationGetAllResponseDto> {
const notifications = await this.notificationRepository.findAll(parameters);

return {
items: result.items.map((item) => item.toObject()),
items: notifications.items.map((item) => item.toObject()),
totalItems: notifications.totalItems,
};
}

Expand Down
17 changes: 12 additions & 5 deletions apps/backend/src/modules/projects/project.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,19 @@ class ProjectController extends BaseController {
): Promise<APIHandlerResponse> {
const { name, page, pageSize } = options.query;

if (page && pageSize) {
return {
payload: await this.projectService.findAll({
name,
page: Number(page),
pageSize: Number(pageSize),
}),
status: HTTPCode.OK,
};
}

return {
payload: await this.projectService.findAll({
name,
page: Number(page),
pageSize: Number(pageSize),
}),
payload: await this.projectService.findAllWithoutPagination(),
status: HTTPCode.OK,
};
}
Expand Down
9 changes: 9 additions & 0 deletions apps/backend/src/modules/projects/project.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class ProjectRepository implements Repository {
};
}

public async findAllWithoutPagination(): Promise<ProjectEntity[]> {
const projects = await this.projectModel
.query()
.orderBy("created_at", SortType.DESCENDING)
.execute();

return projects.map((project) => ProjectEntity.initialize(project));
}

public async findByName(name: string): Promise<null | ProjectEntity> {
const item = await this.projectModel.query().findOne({ name });

Expand Down
8 changes: 8 additions & 0 deletions apps/backend/src/modules/projects/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ class ProjectService implements Service {
};
}

public async findAllWithoutPagination(): Promise<
ProjectGetAllItemResponseDto[]
> {
const projects = await this.projectRepository.findAllWithoutPagination();

return projects.map((project) => project.toObject());
}

public async findInactiveProjects(
thresholdInDays: number,
): Promise<ProjectGetAllItemResponseDto[]> {
Expand Down
Loading

0 comments on commit f274e3b

Please sign in to comment.