|
| 1 | +import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; |
| 2 | +import { Type } from "class-transformer"; |
| 3 | +import { IsIn, IsInt, IsOptional, IsString, Max, Min } from "class-validator"; |
| 4 | + |
| 5 | +export type OpenToWorkAvailability = "FULL_TIME" | "PART_TIME"; |
| 6 | + |
| 7 | +/** |
| 8 | + * Query filters for the open-to-work Talent report. |
| 9 | + * |
| 10 | + * The reports UI uses these filters to page through deployment-ready members |
| 11 | + * and to request role-specific CSV exports. |
| 12 | + */ |
| 13 | +export class OpenToWorkTalentQueryDto { |
| 14 | + @ApiPropertyOptional({ |
| 15 | + description: |
| 16 | + "Preferred role value from the openToWork personalization trait.", |
| 17 | + example: "FULL_STACK_DEVELOPER", |
| 18 | + }) |
| 19 | + @IsOptional() |
| 20 | + @IsString() |
| 21 | + role?: string; |
| 22 | + |
| 23 | + @ApiPropertyOptional({ |
| 24 | + description: |
| 25 | + "Availability value from the openToWork personalization trait.", |
| 26 | + enum: ["FULL_TIME", "PART_TIME"], |
| 27 | + }) |
| 28 | + @IsOptional() |
| 29 | + @IsIn(["FULL_TIME", "PART_TIME"]) |
| 30 | + availability?: OpenToWorkAvailability; |
| 31 | + |
| 32 | + @ApiPropertyOptional({ |
| 33 | + description: "Page number (1-based). Defaults to 1.", |
| 34 | + minimum: 1, |
| 35 | + default: 1, |
| 36 | + }) |
| 37 | + @IsOptional() |
| 38 | + @IsInt() |
| 39 | + @Min(1) |
| 40 | + @Type(() => Number) |
| 41 | + page?: number; |
| 42 | + |
| 43 | + @ApiPropertyOptional({ |
| 44 | + description: "Number of results per page. Defaults to 10, maximum 100.", |
| 45 | + minimum: 1, |
| 46 | + maximum: 100, |
| 47 | + default: 10, |
| 48 | + }) |
| 49 | + @IsOptional() |
| 50 | + @IsInt() |
| 51 | + @Min(1) |
| 52 | + @Max(100) |
| 53 | + @Type(() => Number) |
| 54 | + perPage?: number; |
| 55 | +} |
| 56 | + |
| 57 | +/** |
| 58 | + * Preferred-role aggregate for the open-to-work Talent report. |
| 59 | + */ |
| 60 | +export class OpenToWorkTalentRoleCountDto { |
| 61 | + @ApiProperty({ description: "Preferred role value." }) |
| 62 | + role!: string; |
| 63 | + |
| 64 | + @ApiProperty({ |
| 65 | + description: "Number of open-to-work members with this role.", |
| 66 | + }) |
| 67 | + count!: number; |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * Member row returned to the reports UI Talent tab. |
| 72 | + */ |
| 73 | +export class OpenToWorkTalentMemberDto { |
| 74 | + @ApiProperty({ description: "Member user ID." }) |
| 75 | + userId!: string; |
| 76 | + |
| 77 | + @ApiProperty({ description: "Topcoder handle." }) |
| 78 | + handle!: string; |
| 79 | + |
| 80 | + @ApiPropertyOptional({ description: "First name.", nullable: true }) |
| 81 | + firstName!: string | null; |
| 82 | + |
| 83 | + @ApiPropertyOptional({ description: "Last name.", nullable: true }) |
| 84 | + lastName!: string | null; |
| 85 | + |
| 86 | + @ApiPropertyOptional({ |
| 87 | + description: "Country or country code.", |
| 88 | + nullable: true, |
| 89 | + }) |
| 90 | + country!: string | null; |
| 91 | + |
| 92 | + @ApiPropertyOptional({ |
| 93 | + description: "Open-to-work availability value.", |
| 94 | + nullable: true, |
| 95 | + }) |
| 96 | + availability!: string | null; |
| 97 | + |
| 98 | + @ApiProperty({ description: "Preferred role values.", type: [String] }) |
| 99 | + preferredRoles!: string[]; |
| 100 | + |
| 101 | + @ApiPropertyOptional({ description: "Member signup date.", nullable: true }) |
| 102 | + memberSince!: string | null; |
| 103 | + |
| 104 | + @ApiPropertyOptional({ |
| 105 | + description: "Highest Topcoder rating.", |
| 106 | + nullable: true, |
| 107 | + }) |
| 108 | + maxRating!: number | null; |
| 109 | + |
| 110 | + @ApiProperty({ description: "First-place challenge wins." }) |
| 111 | + challengeWins!: number; |
| 112 | + |
| 113 | + @ApiProperty({ description: "First-place task wins." }) |
| 114 | + taskWins!: number; |
| 115 | + |
| 116 | + @ApiProperty({ description: "Combined first-place challenge and task wins." }) |
| 117 | + totalWins!: number; |
| 118 | +} |
| 119 | + |
| 120 | +/** |
| 121 | + * Dashboard response for the reports UI Talent tab. |
| 122 | + */ |
| 123 | +export class OpenToWorkTalentResponseDto { |
| 124 | + @ApiProperty({ description: "Distinct open-to-work member count." }) |
| 125 | + totalMembers!: number; |
| 126 | + |
| 127 | + @ApiProperty({ description: "Members matching the selected filters." }) |
| 128 | + total!: number; |
| 129 | + |
| 130 | + @ApiProperty({ description: "Current page number." }) |
| 131 | + page!: number; |
| 132 | + |
| 133 | + @ApiProperty({ description: "Results per page." }) |
| 134 | + perPage!: number; |
| 135 | + |
| 136 | + @ApiProperty({ type: [OpenToWorkTalentRoleCountDto] }) |
| 137 | + roleCounts!: OpenToWorkTalentRoleCountDto[]; |
| 138 | + |
| 139 | + @ApiProperty({ type: [OpenToWorkTalentMemberDto] }) |
| 140 | + data!: OpenToWorkTalentMemberDto[]; |
| 141 | +} |
0 commit comments