Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cv field on user #73

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend-8tech",
"version": "4.2.4",
"version": "4.2.5",
"description": "",
"author": "8tech",
"private": true,
Expand Down
21 changes: 21 additions & 0 deletions prisma/migrations/20240124195410_added_cv_on_user/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ model User {
previousWorkplaceId String[]
previousWorkplaceCount Int?
ratings Rating[]
ratingsAvg Float?
cv String?
companyId String?
portfolio String[] @map("portfolio")
profilePicture String?
Expand Down
2 changes: 1 addition & 1 deletion src/users/test/users.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/users/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export class UserRepository {
'-previousWorkplace': {
previousWorkplaceCount: 'desc',
},
ratings: { ratingsAvg: 'asc' },
'-ratings': {
ratingsAvg: 'desc',
},
};

this.field = {
Expand Down Expand Up @@ -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,
Expand Down
Loading