diff --git a/package-lock.json b/package-lock.json index c3b0a98..a4fb148 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "backend-8tech", - "version": "4.2.7", + "version": "4.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "backend-8tech", - "version": "4.2.7", + "version": "4.2.8", "license": "UNLICENSED", "dependencies": { "@nestjs/common": "^9.4.3", diff --git a/package.json b/package.json index 5cdb26a..28f0f93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend-8tech", - "version": "4.2.7", + "version": "4.2.8", "description": "", "author": "8tech", "private": true, diff --git a/prisma/schema.prisma b/prisma/schema.prisma index f2a7646..3785ead 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,26 +14,24 @@ datasource db { } model User { - id String @id @default(uuid()) - email String @unique - username String @unique - firstName String - lastName String - password String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - roles Role[] @default([USER]) - description String? - previousWorkplaceId String[] - previousWorkplaceCount Int? - ratings Rating[] - cv String? - companyId String? - portfolio String[] @map("portfolio") - profilePicture String? - hasGoogleAccount Boolean @default(false) - company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade) - contract Contract[] + id String @id @default(uuid()) + email String @unique + username String @unique + firstName String + lastName String + password String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + roles Role[] @default([USER]) + description String? + ratings Rating[] + cv String? + companyId String? + portfolio String[] @map("portfolio") + profilePicture String? + hasGoogleAccount Boolean @default(false) + company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade) + contract Contract[] } model JobVacancy { @@ -42,9 +40,8 @@ model JobVacancy { description String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - // company Id is optional for current development purposes company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade) - companyId String? + companyId String contracts Contract[] } diff --git a/prisma/seed.ts b/prisma/seed.ts index 7fd1302..0687d88 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -53,29 +53,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'default richard description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const defaultUser = await prisma.user.upsert({ @@ -89,29 +66,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'default user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const notADefaultUser = await prisma.user.upsert({ @@ -125,15 +79,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'notADefault user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - ], }, }); const mariaMarionetteUser = await prisma.user.upsert({ @@ -148,22 +93,6 @@ async function users() { roles: ['USER'], description: 'mariaMarionette user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const mikaUser = await prisma.user.upsert({ @@ -177,29 +106,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'mika user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const sonnyUser = await prisma.user.upsert({ @@ -213,22 +119,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'sonny user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - ], }, }); const ennaUser = await prisma.user.upsert({ @@ -242,29 +132,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'enna user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const satoruUser = await prisma.user.upsert({ @@ -278,29 +145,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'satoru user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const eyePatchUser = await prisma.user.upsert({ @@ -314,29 +158,6 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'eyePatch user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); const ricatUser = await prisma.user.upsert({ @@ -350,56 +171,22 @@ async function users() { password: hashPassword('User123_'), roles: ['USER'], description: 'ricat user description that being created by seed.ts', - previousWorkplaceId: [ - await prisma.company - .findFirst({ - where: { - name: 'Nijisanji Anycolor', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Hololive', - }, - }) - .then((company) => company.id), - await prisma.company - .findFirst({ - where: { - name: 'Djarum', - }, - }) - .then((company) => company.id), - ], }, }); console.log('Created recruiter user: ', recruiter); console.log( - await [ - admin, - defaultUser, - notADefaultUser, - mariaMarionetteUser, - mikaUser, - sonnyUser, - ennaUser, - satoruUser, - eyePatchUser, - ricatUser, - richardWilliam, - ].map(async (user) => { - await prisma.user.update({ - where: { - id: user.id, - }, - data: { - previousWorkplaceCount: user.previousWorkplaceId.length, - }, - }); - }), + admin, + defaultUser, + notADefaultUser, + mariaMarionetteUser, + mikaUser, + sonnyUser, + ennaUser, + satoruUser, + eyePatchUser, + ricatUser, + richardWilliam, ); } diff --git a/src/users/interface/user.interface.ts b/src/users/interface/user.interface.ts index 7b0da95..123d4e9 100644 --- a/src/users/interface/user.interface.ts +++ b/src/users/interface/user.interface.ts @@ -10,7 +10,6 @@ export interface IUser { updatedAt: Date; roles: string[] | Role[]; description: string; - previousWorkplaceId?: any; ratings?: any; companyId?: string; portfolio: string[]; diff --git a/src/users/test/users.controller.spec.ts b/src/users/test/users.controller.spec.ts index 5fac361..ab4fe22 100644 --- a/src/users/test/users.controller.spec.ts +++ b/src/users/test/users.controller.spec.ts @@ -60,8 +60,6 @@ describe('AuthController', () => { password: 'password', companyId: '1', portfolio: ['1', '2'], - previousWorkplaceCount: 0, - previousWorkplaceId: ['1', '2'], profilePicture: 'picture', cv: 'cv', }; diff --git a/src/users/user.repository.ts b/src/users/user.repository.ts index 6ca61ae..788d5df 100644 --- a/src/users/user.repository.ts +++ b/src/users/user.repository.ts @@ -20,12 +20,6 @@ export class UserRepository { '-createdAt': { createdAt: 'desc' }, description: { description: 'asc' }, '-description': { description: 'desc' }, - previousWorkplace: { - previousWorkplaceCount: 'asc', - }, - '-previousWorkplace': { - previousWorkplaceCount: 'desc', - }, }; this.field = { @@ -36,13 +30,6 @@ export class UserRepository { }, }; }, - previousWorkplaceId(keyword: string) { - return { - previousWorkplaceId: { - has: keyword || '', - }, - }; - }, }; } @@ -85,7 +72,6 @@ export class UserRepository { async create(user: any): Promise { const data = { ...user, - previousWorkplaceCount: user.previousWorkplaceId?.length, }; return this.prisma.user.create({ data,