Skip to content

Commit

Permalink
Merge pull request #155 from boostcampwm2023/feat/154-diary-sentiment
Browse files Browse the repository at this point in the history
[Feat] 일기 저장 시 감정 분석 결과 저장
  • Loading branch information
JoonSoo-Kim authored Nov 28, 2023
2 parents eb32f67 + 7364c07 commit 97c0908
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 36 deletions.
89 changes: 66 additions & 23 deletions BE/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions BE/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@liaoliaots/nestjs-redis": "^9.0.5",
"@nestjs/axios": "^3.0.1",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
Expand All @@ -32,6 +33,7 @@
"@types/dotenv": "^8.2.0",
"@types/passport-jwt": "^3.0.13",
"aws-sdk": "^2.1499.0",
"axios": "^1.6.2",
"bcryptjs": "^2.4.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand Down
2 changes: 2 additions & 0 deletions BE/src/diaries/diaries.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { TagsModule } from "src/tags/tags.module";
import { ShapesModule } from "src/shapes/shapes.module";
import { ShapesRepository } from "src/shapes/shapes.repository";
import { TagsRepository } from "src/tags/tags.repository";
import { HttpModule } from "@nestjs/axios";

@Module({
imports: [
TypeOrmModule.forFeature([Diary]),
AuthModule,
TagsModule,
ShapesModule,
HttpModule,
],
controllers: [DiariesController],
providers: [
Expand Down
22 changes: 12 additions & 10 deletions BE/src/diaries/diaries.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Shape } from "src/shapes/shapes.entity";
import { NotFoundException } from "@nestjs/common";
import { Tag } from "src/tags/tags.entity";
import { ReadDiaryDto } from "./dto/diaries.read.dto";
import { SentimentDto } from "./dto/diaries.sentiment.dto";

export class DiariesRepository {
async createDiary(
Expand All @@ -18,15 +19,16 @@ export class DiariesRepository {
tags: Tag[],
user: User,
shape: Shape,
sentimentResult: SentimentDto,
): Promise<Diary> {
const { title, point, date } = createDiaryDto;
const content = encodedContent;

// 미구현 기능을 대체하기 위한 임시 값
const positiveRatio = 0.0;
const negativeRatio = 100.0;
const neutralRatio = 0.0;
const sentiment = sentimentStatus.NEUTRAL;
const positiveRatio = sentimentResult.positiveRatio;
const negativeRatio = sentimentResult.negativeRatio;
const neutralRatio = sentimentResult.neutralRatio;
const sentiment = sentimentStatus[sentimentResult.sentiment];

const newDiary = Diary.create({
title,
Expand Down Expand Up @@ -64,18 +66,18 @@ export class DiariesRepository {
tags: Tag[],
user: User,
shape: Shape,
sentimentResult: SentimentDto,
): Promise<Diary> {
const { uuid, title, point, date } = updateDiaryDto;
const content = encryptedContent;

// 미구현 기능을 대체하기 위한 임시 값
const positiveRatio = 0.0;
const negativeRatio = 100.0;
const neutralRatio = 0.0;
const sentiment = sentimentStatus.NEUTRAL;

const diary = await this.getDiaryByUuid(uuid);

const positiveRatio = sentimentResult.positiveRatio;
const negativeRatio = sentimentResult.negativeRatio;
const neutralRatio = sentimentResult.neutralRatio;
const sentiment = sentimentStatus[sentimentResult.sentiment.toUpperCase()];

Object.assign(diary, {
title,
content,
Expand Down
Loading

0 comments on commit 97c0908

Please sign in to comment.