From 163d9597af92db878bc69a31afd203148d433327 Mon Sep 17 00:00:00 2001 From: richard483 Date: Thu, 25 Jan 2024 02:55:22 +0700 Subject: [PATCH 1/2] added cv field on user --- package-lock.json | 4 ++-- package.json | 2 +- .../migration.sql | 21 +++++++++++++++++++ prisma/schema.prisma | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20240124195410_added_cv_on_user/migration.sql diff --git a/package-lock.json b/package-lock.json index db99e91..a0b1b67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "backend-8tech", - "version": "4.2.4", + "version": "4.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "backend-8tech", - "version": "4.2.4", + "version": "4.2.5", "license": "UNLICENSED", "dependencies": { "@nestjs/common": "^9.4.3", diff --git a/package.json b/package.json index c28bb26..54d7f99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend-8tech", - "version": "4.2.4", + "version": "4.2.5", "description": "", "author": "8tech", "private": true, diff --git a/prisma/migrations/20240124195410_added_cv_on_user/migration.sql b/prisma/migrations/20240124195410_added_cv_on_user/migration.sql new file mode 100644 index 0000000..8c6b1b1 --- /dev/null +++ b/prisma/migrations/20240124195410_added_cv_on_user/migration.sql @@ -0,0 +1,21 @@ +/* + Warnings: + + - The values [FAILED] on the enum `PaymentStatus` will be removed. If these variants are still used in the database, this will fail. + - You are about to drop the column `ratingsAvg` on the `User` table. All the data in the column will be lost. + +*/ +-- AlterEnum +BEGIN; +CREATE TYPE "PaymentStatus_new" AS ENUM ('PENDING', 'PAID', 'ACCEPTED'); +ALTER TABLE "Payment" ALTER COLUMN "paymentStatus" DROP DEFAULT; +ALTER TABLE "Payment" ALTER COLUMN "paymentStatus" TYPE "PaymentStatus_new" USING ("paymentStatus"::text::"PaymentStatus_new"); +ALTER TYPE "PaymentStatus" RENAME TO "PaymentStatus_old"; +ALTER TYPE "PaymentStatus_new" RENAME TO "PaymentStatus"; +DROP TYPE "PaymentStatus_old"; +ALTER TABLE "Payment" ALTER COLUMN "paymentStatus" SET DEFAULT 'PENDING'; +COMMIT; + +-- AlterTable +ALTER TABLE "User" DROP COLUMN "ratingsAvg", +ADD COLUMN "cv" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 488bb1f..e4f5f53 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -27,7 +27,7 @@ model User { previousWorkplaceId String[] previousWorkplaceCount Int? ratings Rating[] - ratingsAvg Float? + cv String? companyId String? portfolio String[] @map("portfolio") profilePicture String? From 7d33b17ef5d0391447b3515f990ec904989dcaed Mon Sep 17 00:00:00 2001 From: richard483 Date: Thu, 25 Jan 2024 03:02:30 +0700 Subject: [PATCH 2/2] removed all ratings data usage & update test --- src/users/test/users.controller.spec.ts | 2 +- src/users/user.repository.ts | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/users/test/users.controller.spec.ts b/src/users/test/users.controller.spec.ts index b8b7891..5fac361 100644 --- a/src/users/test/users.controller.spec.ts +++ b/src/users/test/users.controller.spec.ts @@ -58,12 +58,12 @@ describe('AuthController', () => { hasGoogleAccount: false, description: 'desc', password: 'password', - ratingsAvg: 0, companyId: '1', portfolio: ['1', '2'], previousWorkplaceCount: 0, previousWorkplaceId: ['1', '2'], profilePicture: 'picture', + cv: 'cv', }; const createSpy = jest diff --git a/src/users/user.repository.ts b/src/users/user.repository.ts index 28418ef..41d958c 100644 --- a/src/users/user.repository.ts +++ b/src/users/user.repository.ts @@ -26,10 +26,6 @@ export class UserRepository { '-previousWorkplace': { previousWorkplaceCount: 'desc', }, - ratings: { ratingsAvg: 'asc' }, - '-ratings': { - ratingsAvg: 'desc', - }, }; this.field = { @@ -90,10 +86,6 @@ export class UserRepository { const data = { ...user, previousWorkplaceCount: user.previousWorkplaceId?.length, - ratingsAvg: - user.ratings - ?.map((rating) => rating.ratingOf10) - .reduce((a, b) => a + b, 0) / user.ratings?.length, }; return this.prisma.user.create({ data,