Skip to content

Commit ecb3be0

Browse files
committed
test-variation. get details added
1 parent 603e1a8 commit ecb3be0

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/test-variations/test-variations.controller.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Controller, ParseUUIDPipe, Get, UseGuards, Param, Query, Put, Body } from '@nestjs/common';
22
import { ApiTags, ApiParam, ApiBearerAuth, ApiQuery } from '@nestjs/swagger';
33
import { TestVariationsService } from './test-variations.service';
4-
import { TestVariation } from '@prisma/client';
4+
import { TestVariation, Baseline } from '@prisma/client';
55
import { JwtAuthGuard } from '../auth/guards/auth.guard';
66
import { PrismaService } from '../prisma/prisma.service';
77
import { IgnoreAreaDto } from '../test/dto/ignore-area.dto';
@@ -23,6 +23,16 @@ export class TestVariationsController {
2323
});
2424
}
2525

26+
@Get(':id')
27+
@ApiQuery({ name: 'id', required: true })
28+
@ApiBearerAuth()
29+
@UseGuards(JwtAuthGuard)
30+
getDetails(
31+
@Param('id', new ParseUUIDPipe()) id,
32+
): Promise<TestVariation & { baselines: Baseline[] }> {
33+
return this.testVariations.getDetails(id);
34+
}
35+
2636
@Put('ignoreArea/:variationId')
2737
@ApiParam({ name: 'variationId', required: true })
2838
@ApiBearerAuth()

src/test-variations/test-variations.service.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,30 @@ import { Injectable } from '@nestjs/common';
22
import { CreateTestRequestDto } from '../test/dto/create-test-request.dto';
33
import { IgnoreAreaDto } from '../test/dto/ignore-area.dto';
44
import { PrismaService } from '../prisma/prisma.service';
5-
import { TestVariation } from '@prisma/client';
5+
import { TestVariation, Baseline } from '@prisma/client';
66

77
@Injectable()
88
export class TestVariationsService {
99
constructor(
1010
private prismaService: PrismaService,
1111
) { }
1212

13+
async getDetails(id: string): Promise<TestVariation & { baselines: Baseline[] }> {
14+
return this.prismaService.testVariation.findOne({
15+
where: { id },
16+
include: {
17+
baselines: {
18+
include: {
19+
testRun: true,
20+
},
21+
orderBy: {
22+
createdAt: 'desc'
23+
}
24+
},
25+
},
26+
});
27+
}
28+
1329
async findOrCreate(createTestDto: CreateTestRequestDto): Promise<TestVariation> {
1430
const data = {
1531
name: createTestDto.name,

0 commit comments

Comments
 (0)