Skip to content

Commit 06e8d63

Browse files
authored
Feat: (solo project) Add solo project status, email and discordId query params to GET endpoint
* remove unused endpoints * move solo project validation pipes to dto * (solo project) move API queries in controller to dto * (solo project) move sort default to dto * (solo project) add status query param to get endpoint * (solo project) fix optional param types * (solo project) fix optional param types * (solo project) add query params for discordId and email * update changelog
1 parent 8aaba2c commit 06e8d63

File tree

13 files changed

+161
-124
lines changed

13 files changed

+161
-124
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
- Added release please github actions ([#235])(https://github.com/chingu-x/chingu-dashboard-be/pull/235)
2121
- Added version release link to Swagger docs ([#218](https://github.com/chingu-x/chingu-dashboard-be/pull/231))
22+
- Added status, email, discordId query to solo project get endpoint ([#237](https://github.com/chingu-x/chingu-dashboard-be/pull/237))
2223

2324
### Changed
2425

2526
- Updated readme for installation part ([#225])(https://github.com/chingu-x/chingu-dashboard-be/pull/225)
2627
- Updated nestjs packages to latest version ([#233])(https://github.com/chingu-x/chingu-dashboard-be/pull/233)
2728
- Refactoring of email service + unit tests ([#232](https://github.com/chingu-x/chingu-dashboard-be/pull/232))
29+
- Refactored solo project get endpoint input validation ([#237](https://github.com/chingu-x/chingu-dashboard-be/pull/237))
2830

2931
### Fixed
3032
- fixed POST voyages/teams/{teamId}/techs bug , verify that categoryId is owned by correct team ([#229](https://github.com/chingu-x/chingu-dashboard-be/pull/229))

prisma/seed/solo-project.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { prisma } from "./prisma-client";
44

55
export const populateSoloProjects = async () => {
66
// solo project status
7+
// TODO update this to generate from global/constants/statuses
78
await prisma.soloProjectStatus.createMany({
89
data: [
910
{ status: "Waiting Evaluation" },

src/features/features.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Injectable,
55
NotFoundException,
66
} from "@nestjs/common";
7-
import { PrismaService } from "../prisma/prisma.service";
7+
import { PrismaService } from "@/prisma/prisma.service";
88
import { CreateFeatureDto } from "./dto/create-feature.dto";
99
import { UpdateFeatureDto } from "./dto/update-feature.dto";
1010
import { UpdateFeatureOrderAndCategoryDto } from "./dto/update-feature-order-and-category.dto";

src/global/constants/roles.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// voyage project roles
2+
export const soloProjectVoyageRoles = [
3+
"Developer",
4+
"Product Owner",
5+
"Scrum Master",
6+
"Data Scientist",
7+
"UI/UX Designer",
8+
];
9+
10+
export const voyageRoles = [...soloProjectVoyageRoles, "Voyage Guide"];
11+
12+
// app roles

src/global/constants/sortMaps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ export const soloProjectSortMap: Map<string, string> = new Map(
1010
updatedAt: "updatedAt",
1111
}),
1212
);
13+
14+
export const soloProjectSortMapKeys: string[] = Array.from(
15+
soloProjectSortMap.keys(),
16+
);

src/global/constants/statuses.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const soloProjectStatuses = [
2+
"Waiting Evaluation",
3+
"Requested Changes",
4+
"Passed",
5+
"No Pass",
6+
"No Response",
7+
"Not in Discord",
8+
];
9+
10+
// application statuses
11+
12+
// voyage application & voyage statuses
13+
14+
// user statuses

src/global/global.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { PrismaService } from "@/prisma/prisma.service";
88
import { CustomRequest } from "./types/CustomRequest";
99
import { FormResponseDto } from "./dtos/FormResponse.dto";
1010
import { UserWithProfile } from "@/global/types/users.types";
11+
import { soloProjectSortMapKeys } from "@/global/constants/sortMaps";
1112

1213
@Injectable()
1314
export class GlobalService {
@@ -243,7 +244,7 @@ export class GlobalService {
243244
: field;
244245
if (!sortFieldMap.get(fieldName))
245246
throw new BadRequestException(
246-
`Sort field ${fieldName} is not valid.`,
247+
`Sort field '${fieldName}' is not valid. Valid sort fields: ${soloProjectSortMapKeys.join(", ")}`,
247248
);
248249
return {
249250
[sortFieldMap.get(fieldName)!]: direction,

src/pipes/non-negative-int-default-value-pipe.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/solo-projects/dto/create-solo-project.dto.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {
2+
IsEmail,
3+
IsIn,
4+
IsNumber,
5+
IsOptional,
6+
IsPositive,
7+
IsString,
8+
Min,
9+
} from "class-validator";
10+
import { Type } from "class-transformer";
11+
import { soloProjectStatuses } from "@/global/constants/statuses";
12+
import { ApiProperty } from "@nestjs/swagger";
13+
import { soloProjectVoyageRoles } from "@/global/constants/roles";
14+
15+
export class GetSoloProjectDto {
16+
@IsOptional()
17+
@IsNumber()
18+
@Min(0)
19+
@Type(() => Number)
20+
@ApiProperty({
21+
name: "offset",
22+
type: Number,
23+
description: "Offset for pagination (default: 0)",
24+
required: false,
25+
})
26+
offset: number = 0;
27+
28+
@IsOptional()
29+
@IsPositive()
30+
@Type(() => Number)
31+
@ApiProperty({
32+
name: "pageSize",
33+
type: Number,
34+
description:
35+
"page size (number of results) for pagination (default: 30)",
36+
required: false,
37+
})
38+
pageSize: number = 30;
39+
40+
@IsOptional()
41+
@ApiProperty({
42+
name: "sort",
43+
type: String,
44+
description:
45+
"Sort. - for descending, + (or nothing) for ascending (default: -createdAt)" +
46+
"<br/> Example: '+status;-createdAt' will sort by status ascending then createdAt descending" +
47+
"<br/> Valid sort fields are: 'status', 'createdAt', 'updatedAt'" +
48+
"<br/> Default: '-createdAt'",
49+
required: false,
50+
})
51+
sort: string = "-createdAt";
52+
53+
@ApiProperty({
54+
enum: soloProjectStatuses,
55+
required: false,
56+
})
57+
@IsOptional()
58+
@IsIn(soloProjectStatuses)
59+
status: string;
60+
61+
@ApiProperty({
62+
enum: soloProjectVoyageRoles,
63+
required: false,
64+
})
65+
@IsOptional()
66+
@IsIn(soloProjectVoyageRoles)
67+
voyageRoles: string;
68+
69+
@ApiProperty({
70+
required: false,
71+
description: "User email",
72+
})
73+
@IsOptional()
74+
@IsEmail()
75+
email: string;
76+
77+
@ApiProperty({
78+
required: false,
79+
description: "Discord ID, not discord nickname",
80+
})
81+
@IsOptional()
82+
@IsString()
83+
discordId: string;
84+
}

0 commit comments

Comments
 (0)