Skip to content

Завершаем проектировать базу данных - #7

Merged
keksobot merged 2 commits into
htmlacademy-nodejs-api:masterfrom
MikhailBespyatov:module5-task2
Oct 26, 2025
Merged

keksobot merged 2 commits into
htmlacademy-nodejs-api:masterfrom
MikhailBespyatov:module5-task2

Conversation

@MikhailBespyatov

@MikhailBespyatov MikhailBespyatov commented Oct 25, 2025 •

Copy link
Copy Markdown

@keksobot keksobot changed the title module5-task2 Завершаем проектировать базу данных Oct 25, 2025

@NaumovEvgeniy NaumovEvgeniy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Непонятно почему решил вынести рейтинг в отдельную сущность. Я бы оставил его в CommentEntity. Это гораздо проще поддерживать.

Еще, ты не правильно понял смысл избранного. Флаг избранного должен привязываться к офферу и пользователю. Сейчас флаг избранного находится в моделе OfferEntity и это не верно. Если ты у оффера выставишь isFavorite: true, то это предложение будет избранное для всех пользователей, а это не верно.

Нужно сделать отдельную модель для избранного. В ней будет храниться связь пользователя и предложения.

userId offerId
u1 o1
u1 o2
u2 o2

Пример этой таблицы. Тут у пользователя u1 добавлено в избранное 2 оффера (o1 и o2), а у пользователя u2 только одно предложение в избранном. А у остальных пользователей в избранном ничего нет

Comment thread src/shared/modules/favorite/favorite.entity.ts
Comment thread src/shared/modules/comment-rating/default-comment-rating.service.ts Outdated
Comment thread src/main.rest.ts Outdated
createUserContainer(appContainer);
createOfferContainer(appContainer);
createCommentContainer(appContainer);
createOfferRatingContainer(appContainer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужно (смотир комментарии ниже)

Comment thread src/shared/modules/comment-rating/comment-rating-service.interface.ts Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если хранить рейтинг в CommentEntity в этой дто уже нет необходимости

@@ -1,6 +1,5 @@
export class CreateCommentDto {
public text!: string;
public rating!: number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я бы оставил рейтинг тут

Comment thread src/shared/modules/offer-rating/default-offer-rating.service.ts Outdated
Comment thread src/shared/modules/offer-rating/dto/create-offer-rating.dto.ts Outdated

public async create(dto: CreateCommentDto): Promise<DocumentType<CommentEntity>> {
const result = await this.commentModule.create(dto);
const result = await this.commentModel.create({...dto, datePublished: new Date()});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я бы добавил перерасчет рейтинга сюда, когда добавляется комментарий

@NaumovEvgeniy NaumovEvgeniy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил пару комментов. Не думаю что ради них следует отправить на доработку.

public isPremium!: boolean;
public isFavorite!: boolean;
public rating!: number;
public rating?: number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно убрать, тк он расчитывается автоматически

public isPremium!: boolean;
public isFavorite!: boolean;
public rating!: number;
public rating?: number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно убрать, тк он расчитывается автоматически

@keksobot
keksobot merged commit 0644f4b into htmlacademy-nodejs-api:master Oct 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants