Skip to content

Commit

Permalink
Merge pull request #376 from boostcampwm-2024/feat/#374/ai-status
Browse files Browse the repository at this point in the history
[Feat] 대시보드 조회시에 summary 여부 판단 추가
  • Loading branch information
Jieun1ee authored Dec 5, 2024
2 parents 1ee54f7 + 38fae97 commit 3f7ad0a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/api/src/dashboard/dashboard.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { Applicant } from '@/entity/applicant.entity';
import { Summary } from '@/entity/summary.entity';
import { Ticle } from '@/entity/ticle.entity';

import { DashboardController } from './dashboard.controller';
import { DashboardService } from './dashboard.service';

@Module({
imports: [TypeOrmModule.forFeature([Ticle, Applicant])],
imports: [TypeOrmModule.forFeature([Ticle, Applicant, Summary])],
controllers: [DashboardController],
providers: [DashboardService],
})
Expand Down
30 changes: 26 additions & 4 deletions apps/api/src/dashboard/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Repository } from 'typeorm';
import { ErrorMessage, TicleStatus } from '@repo/types';

import { Applicant } from '@/entity/applicant.entity';
import { Summary } from '@/entity/summary.entity';
import { Ticle } from '@/entity/ticle.entity';

@Injectable()
Expand All @@ -12,7 +13,9 @@ export class DashboardService {
@InjectRepository(Ticle)
private readonly ticleRepository: Repository<Ticle>,
@InjectRepository(Applicant)
private readonly applicantRepository: Repository<Applicant>
private readonly applicantRepository: Repository<Applicant>,
@InjectRepository(Summary)
private readonly summaryRepository: Repository<Summary>
) {}

async getCreatedTicleList(
Expand All @@ -25,7 +28,15 @@ export class DashboardService {

const queryBuilder = this.ticleRepository
.createQueryBuilder('ticle')
.select(['ticle.id', 'ticle.title', 'ticle.startTime', 'ticle.endTime', 'ticle.ticleStatus'])
.leftJoin('ticle.summary', 'summary')
.select([
'ticle.id',
'ticle.title',
'ticle.startTime',
'ticle.endTime',
'ticle.ticleStatus',
'summary.id',
])
.where('ticle.speaker = :speakerId', { speakerId })
.skip(skip)
.take(pageSize);
Expand All @@ -40,7 +51,12 @@ export class DashboardService {
}
}

const [ticles, totalItems] = await queryBuilder.getManyAndCount();
const [ticle, totalItems] = await queryBuilder.getManyAndCount();

const ticles = ticle.map((ticle) => ({
...ticle,
summary: ticle.summary ? ticle.summary.id !== null : false,
}));

const totalPages = Math.ceil(totalItems / pageSize);

Expand All @@ -62,6 +78,7 @@ export class DashboardService {
const queryBuilder = this.applicantRepository
.createQueryBuilder('applicant')
.leftJoinAndSelect('applicant.ticle', 'ticle')
.leftJoin('ticle.summary', 'summary')
.select([
'applicant.id',
'ticle.id',
Expand All @@ -70,6 +87,7 @@ export class DashboardService {
'ticle.startTime',
'ticle.endTime',
'ticle.ticleStatus',
'summary.id',
])
.where('applicant.user = :userId', { userId })
.skip(skip)
Expand All @@ -87,7 +105,11 @@ export class DashboardService {

const [applicants, totalItems] = await queryBuilder.getManyAndCount();

const ticles = applicants.map((applicant) => applicant.ticle);
const ticles = applicants.map((applicant) => ({
...applicant.ticle,
summary: applicant.ticle.summary ? applicant.ticle.summary.id !== null : false,
}));

const totalPages = Math.ceil(totalItems / pageSize);

return {
Expand Down

0 comments on commit 3f7ad0a

Please sign in to comment.