Commit 7fe4d144 by Augusto

MVP

parent 65bf6dc7
...@@ -107,6 +107,7 @@ export class CandidatesService { ...@@ -107,6 +107,7 @@ export class CandidatesService {
} }
}, },
comments: { comments: {
take: 1,
include: { include: {
createdBy: { createdBy: {
select: { select: {
...@@ -139,7 +140,13 @@ export class CandidatesService { ...@@ -139,7 +140,13 @@ export class CandidatesService {
const candidate = await this.prisma.candidate.findUnique({ const candidate = await this.prisma.candidate.findUnique({
where: { id }, where: { id },
include: { include: {
sites: {
include: {
site: true
}
},
comments: { comments: {
take: 1,
include: { include: {
createdBy: { createdBy: {
select: { select: {
......
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { CandidateType, CandidateStatus } from './create-candidate.dto'; import { CandidateType, CandidateStatus } from './create-candidate.dto';
import { CommentResponseDto } from '../../comments/dto/comment-response.dto'; import { CommentResponseDto } from '../../comments/dto/comment-response.dto';
import { SiteResponseDto } from '../../sites/dto/site-response.dto';
export class CandidateSiteDto {
@ApiProperty({ description: 'CandidateSite ID' })
id: number;
@ApiProperty({ description: 'Site associated with this candidate' })
site: SiteResponseDto;
@ApiProperty({ description: 'Creation timestamp' })
createdAt: Date;
@ApiProperty({ description: 'Last update timestamp' })
updatedAt: Date;
}
export class CandidateResponseDto { export class CandidateResponseDto {
@ApiProperty({ description: 'Candidate ID' }) @ApiProperty({ description: 'Candidate ID' })
...@@ -27,8 +42,8 @@ export class CandidateResponseDto { ...@@ -27,8 +42,8 @@ export class CandidateResponseDto {
@ApiProperty({ description: 'Whether the candidate is ongoing' }) @ApiProperty({ description: 'Whether the candidate is ongoing' })
onGoing: boolean; onGoing: boolean;
@ApiProperty({ description: 'ID of the site this candidate belongs to' }) @ApiProperty({ description: 'Sites associated with this candidate', type: [CandidateSiteDto] })
siteId: number; sites: CandidateSiteDto[];
@ApiProperty({ description: 'Creation timestamp' }) @ApiProperty({ description: 'Creation timestamp' })
createdAt: Date; createdAt: Date;
......
...@@ -195,18 +195,23 @@ export class SitesService { ...@@ -195,18 +195,23 @@ export class SitesService {
email: true, email: true,
}, },
}, },
comments: {
take: 1,
include: {
createdBy: {
select: {
id: true,
name: true,
email: true,
}, },
}, },
}, },
orderBy: { orderBy: {
candidate: { createdAt: 'desc',
candidateCode: 'asc', },
}, },
}, },
}, },
_count: {
select: {
candidates: true,
}, },
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment