Passed
Push — development ( 223a11...811359 )
by Karl
24:36 queued 11:37
created

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

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 105
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 95.83%

Importance

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