Passed
Pull Request — development (#85)
by Karl
11:15
created

backend/src/bicycles/dto/batch-update.dto.ts

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 103
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 95.45%

Importance

Changes 0
Metric Value
eloc 81
dl 0
loc 103
ccs 21
cts 22
cp 0.9545
c 0
b 0
f 0
wmc 0
mnd 0
bc 0
fnc 0
bpm 0
cpm 0
noi 80
1 4
import { ApiProperty } from '@nestjs/swagger';
2 4
import { IsNumber, IsUUID, ValidateNested, IsArray } from 'class-validator';
3 4
import { Type } from 'class-transformer';
4 4
import { UpdateBicycleDto } from './update-bicycle.dto';
5
import { BicycleBatchResponse } from '../types/BicycleBatchResponse';
0 ignored issues
show
introduced by
'BicycleBatchResponse' is defined but never used.
Loading history...
6
7 4
export class UpdateBicycleWithIdDto extends UpdateBicycleDto {
8
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
9
        description: 'Unique identifier of the bicycle',
0 ignored issues
show
introduced by
Delete ····
Loading history...
introduced by
Define a constant instead of duplicating this literal 3 times.
Loading history...
10
        example: '123e4567-e89b-12d3-a456-426614174000',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
introduced by
Define a constant instead of duplicating this literal 3 times.
Loading history...
11
        required: true,
0 ignored issues
show
introduced by
Delete ····
Loading history...
12
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
13
    @IsUUID()
0 ignored issues
show
introduced by
Delete ··
Loading history...
14 4
    id: string;
0 ignored issues
show
introduced by
Delete ··
Loading history...
15
}
16
17 4
export class BicyclePositionDto {
18
    @ApiProperty({
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
19
        description: 'Unique identifier of the bicycle',
0 ignored issues
show
introduced by
Delete ····
Loading history...
20
        example: '123e4567-e89b-12d3-a456-426614174000',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
21
        required: true,
0 ignored issues
show
introduced by
Delete ····
Loading history...
22
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
23
    @IsUUID()
0 ignored issues
show
introduced by
Delete ··
Loading history...
24 4
    id: string;
0 ignored issues
show
introduced by
Delete ··
Loading history...
25
26
    @ApiProperty({
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
27
        description: 'Latitude coordinate of the bicycle',
0 ignored issues
show
introduced by
Delete ····
Loading history...
28
        example: 59.3293,
0 ignored issues
show
introduced by
Delete ····
Loading history...
29
        type: Number,
0 ignored issues
show
introduced by
Delete ····
Loading history...
30
        required: true,
0 ignored issues
show
introduced by
Delete ····
Loading history...
31
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
32
    @IsNumber()
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
33 4
    latitude: number;
0 ignored issues
show
introduced by
Delete ··
Loading history...
34
35
    @ApiProperty({
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
36
        description: 'Longitude coordinate of the bicycle',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
37
        example: 18.0686,
0 ignored issues
show
introduced by
Delete ····
Loading history...
38
        type: Number,
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
39
        required: true,
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
40
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
41
    @IsNumber()
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
42 4
    longitude: number;
0 ignored issues
show
introduced by
Delete ··
Loading history...
43
}
44
45 4
export class BatchUpdateBicyclePositionsDto {
46
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
47
        description: 'Array of bicycle position updates',
0 ignored issues
show
introduced by
Delete ····
Loading history...
48
        type: [BicyclePositionDto],
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
49
        required: true,
0 ignored issues
show
introduced by
Delete ····
Loading history...
50
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
51
    @IsArray()
0 ignored issues
show
introduced by
Delete ··
Loading history...
52
    @ValidateNested({ each: true })
0 ignored issues
show
introduced by
Delete ··
Loading history...
53
    @Type(() => BicyclePositionDto)
0 ignored issues
show
introduced by
Delete ··
Loading history...
54 4
    updates: BicyclePositionDto[];
0 ignored issues
show
introduced by
Delete ··
Loading history...
55
}
56
57 4
export class BicycleBatchResponseItem {
58
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
59
        description: 'Unique identifier of the bicycle',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
60
        example: '123e4567-e89b-12d3-a456-426614174000',
0 ignored issues
show
introduced by
Delete ····
Loading history...
61
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
62 4
    id: string;
0 ignored issues
show
introduced by
Delete ··
Loading history...
63
64
    @ApiProperty({
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
65
        description: 'Whether the update was successful',
0 ignored issues
show
introduced by
Delete ····
Loading history...
66
        example: true,
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
67
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
68 4
    success: boolean;
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
69
70
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
71
        description: 'Error message if the update failed',
0 ignored issues
show
introduced by
Delete ····
Loading history...
72
        example: 'Bicycle not found',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
73
        required: false,
0 ignored issues
show
introduced by
Delete ····
Loading history...
74
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
75 4
    error?: string;
0 ignored issues
show
introduced by
Delete ··
Loading history...
76
}
0 ignored issues
show
introduced by
Delete
Loading history...
77
78
79 4
export class BicycleBatchResponseDto {
80
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
81
        type: [BicycleBatchResponseItem],
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
82
        description: 'Array of update results',
0 ignored issues
show
introduced by
Delete ····
Loading history...
83
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
84 4
    results: BicycleBatchResponseItem[];
0 ignored issues
show
introduced by
Delete ··
Loading history...
85
86
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
87
        description: 'Total number of updates attempted',
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
88
        example: 10,
0 ignored issues
show
introduced by
Delete ····
Loading history...
89
    })
0 ignored issues
show
introduced by
Replace ···· with ··
Loading history...
90 4
    totalCount: number;
0 ignored issues
show
introduced by
Delete ··
Loading history...
91
92
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
93
        description: 'Number of successful updates',
0 ignored issues
show
introduced by
Delete ····
Loading history...
94
        example: 8,
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
95
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
96 4
    successCount: number;
0 ignored issues
show
introduced by
Delete ··
Loading history...
97
98
    @ApiProperty({
0 ignored issues
show
introduced by
Delete ··
Loading history...
99
        description: 'Number of failed updates',
0 ignored issues
show
introduced by
Delete ····
Loading history...
100
        example: 2,
0 ignored issues
show
introduced by
Replace ········ with ····
Loading history...
101
    })
0 ignored issues
show
introduced by
Delete ··
Loading history...
102
    failureCount: number;
0 ignored issues
show
introduced by
Delete ··
Loading history...
103
}
0 ignored issues
show
introduced by
Insert
Loading history...