Skip to content

Commit

Permalink
feat: Mentor-Cycle#53 - formatting field years of experience to exper…
Browse files Browse the repository at this point in the history
…ience
  • Loading branch information
daniloMelin committed Jul 12, 2023
1 parent 4eaab3e commit 428a6b7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "years_of_experience" SET DATA TYPE TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:
- You are about to drop the column `years_of_experience` on the `users` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "users" DROP COLUMN "years_of_experience",
ADD COLUMN "experience" TEXT;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ model User {
linkedin String?
github String?
website String?
yearsOfExperience Float? @map("years_of_experience")
experience String? @map("experience")
description String?
jobTitle String? @map("job_title")
jobCompany String? @map("job_company")
Expand Down
6 changes: 3 additions & 3 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type User {
firstName: String!
lastName: String
photoUrl: String
yearsOfExperience: Float
experience: String
isEmailVerified: Boolean!
isTermsAccepted: Boolean!
onBoardingCompleted: Boolean!
Expand Down Expand Up @@ -197,7 +197,7 @@ input CreateUserInput {
email: String!
password: String!
photoUrl: String
yearsOfExperience: Float
experience: String!
skills: [String!]!
birthDate: DateTime
zipCode: String!
Expand All @@ -223,7 +223,7 @@ input UpdateUserDto {
email: String
password: String
photoUrl: String
yearsOfExperience: Float
experience: String
skills: [String!]
birthDate: DateTime
zipCode: String
Expand Down
11 changes: 8 additions & 3 deletions src/modules/user/dto/create-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ export class CreateUserInput {
@IsUrl()
photoUrl?: string;

@Field({ nullable: true })
@Field()
@IsOptional()
yearsOfExperience?: number;
@IsString()
@Length(3, 5)
@Matches(/^[0-9]{1,2}-(10|11|[0-9]{1})$/, {
message: 'experience should be on format "99-99" (years-months)',
})
experience?: string;

@Field(() => [String], { nullable: false })
@IsEnum(Skill, { each: true })
Expand All @@ -68,7 +73,7 @@ export class CreateUserInput {
@IsString()
@Length(9, 9)
@Matches(/^[0-9]{5}-[0-9]{3}/, {
message: 'Zip code should be on format "99999-99"',
message: 'zipCode should be on format "99999-999"',
})
zipCode?: string;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/user/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class User {
lastName?: string | null;
@Field(() => String, { nullable: true })
photoUrl?: string | null;
@Field(() => Float, { nullable: true })
yearsOfExperience?: number | null;
@Field(() => String, { nullable: true })
experience?: string | null;
@Field()
isEmailVerified: boolean;
@Field()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class UserService {
user.city,
user.linkedin,
user.github,
user.yearsOfExperience,
user.experience,
user.description,
user.jobTitle,
user.jobCompany,
Expand Down

0 comments on commit 428a6b7

Please sign in to comment.