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

Release #7963

Merged
merged 2 commits into from
Jul 13, 2024
Merged

Release #7963

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: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@
"allcaps",
"iubgreen",
"unixepoch",
"macbook"
"macbook",
"upvotes",
"downvotes"
],
"useGitignore": true,
"ignorePaths": [
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { JitsuAnalyticsPlugin } from '@gauzy/plugin-jitsu-analytics';
import { JobProposalPlugin } from '@gauzy/plugin-job-proposal';
import { JobSearchPlugin } from '@gauzy/plugin-job-search';
import { KnowledgeBasePlugin } from '@gauzy/plugin-knowledge-base';
// import { ProductReviewsPlugin } from '@gauzy/plugin-product-reviews';
import { ProductReviewsPlugin } from '@gauzy/plugin-product-reviews';

import { SentryTracing as SentryPlugin } from './sentry';

Expand Down Expand Up @@ -48,7 +48,7 @@ export const plugins = [
// Indicates the inclusion or intention to use the JobSearchPlugin in the codebase.
JobSearchPlugin,
// Indicates the inclusion or intention to use the KnowledgeBasePlugin in the codebase.
KnowledgeBasePlugin
KnowledgeBasePlugin,
// Indicates the inclusion or intention to use the ProductReviewsPlugin in the codebase.
// ProductReviewsPlugin
ProductReviewsPlugin
];

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/desktop-libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"better-sqlite3": "^9.4.3",
"electron-store": "^8.1.0",
"electron-util": "^0.17.2",
"electron-log": "^4.4.8",
"embedded-queue": "^0.0.11",
"express": "^4.18.2",
"form-data": "^3.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/product-reviews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@
"tslib": "^2.6.2"
},
"dependencies": {
"@gauzy/contracts": "^0.1.0",
"@gauzy/core": "^0.1.0",
"@gauzy/plugin": "^0.1.0",
"@nestjs/common": "^10.3.7",
"@nestjs/swagger": "^7.3.0",
"@nestjs/typeorm": "^10.0.2",
"apollo-server-core": "^3.10.1",
"chalk": "4.1.2",
"class-validator": "^0.14.0",
"typeorm": "^0.3.20"
},
"devDependencies": {
"@types/jest": "^29.4.4",
"@types/node": "^20.14.9",
"rimraf": "^3.0.2",
"tslint": "^6.1.3",
"typescript": "5.1.6"
},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,109 @@
import { MultiORMEntity, MultiORMColumn, TenantOrganizationBaseEntity } from '@gauzy/core';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { JoinColumn, RelationId } from 'typeorm';
import { IsEnum, IsNotEmpty, IsNumber, IsOptional, IsUUID, Max, Min } from 'class-validator';
import { ID, IProduct, IUser } from '@gauzy/contracts';
import {
MultiORMEntity,
MultiORMColumn,
TenantOrganizationBaseEntity,
Product,
MultiORMManyToOne,
ColumnIndex,
User,
VirtualMultiOrmColumn
} from '@gauzy/core';
import { IProductReview, ProductReviewStatus, ProductReviewStatusEnum } from '../product-review.types';
import { MikroOrmProductReviewRepository } from './repository/mikro-orm-product-review.repository';

@MultiORMEntity('product_review', { mikroOrmRepository: () => MikroOrmProductReviewRepository })
export class ProductReview extends TenantOrganizationBaseEntity {
@MultiORMColumn('text')
body: string;
export class ProductReview extends TenantOrganizationBaseEntity implements IProductReview {
// Title of the review
@ApiPropertyOptional({ type: () => String })
@IsOptional()
@MultiORMColumn({ nullable: true })
title: string;

// Description of the review
@ApiPropertyOptional({ type: () => String })
@IsOptional()
@MultiORMColumn('text', { nullable: true })
description: string;

// Rating of the review
@ApiProperty({ type: () => Number, minimum: 0, maximum: 10 })
@IsNotEmpty()
@IsNumber()
@Min(0)
@Max(10)
@MultiORMColumn()
rating: number;

// Up votes (Positive votes)
@ApiProperty({ type: () => Number })
@IsNumber()
@ColumnIndex()
@MultiORMColumn({ type: 'int', default: 0 })
upvotes: number;

// Down votes (Negative votes)
@ApiProperty({ type: () => Number })
@IsNumber()
@ColumnIndex()
@MultiORMColumn({ type: 'int', default: 0 })
downvotes: number;

// Status of the review
@ApiProperty({ type: () => String, enum: ProductReviewStatusEnum })
@IsEnum(ProductReviewStatusEnum)
@MultiORMColumn({ type: 'varchar', default: ProductReviewStatusEnum.PENDING })
status: ProductReviewStatus;

// Date when the record was edited
@MultiORMColumn({ type: 'timestamp' })
@ColumnIndex()
@MultiORMColumn({ nullable: true })
editedAt: Date;

// Indicates whether the ProductReview has been edited.
@VirtualMultiOrmColumn()
isEdited: boolean;

/*
|--------------------------------------------------------------------------
| @ManyToOne
|--------------------------------------------------------------------------
*/
/**
* Product that is being reviewed
*/
@MultiORMManyToOne(() => Product, {
/** Database cascade action on delete. */
onDelete: 'CASCADE'
})
@JoinColumn()
product?: IProduct;

@ApiProperty({ type: () => String })
@IsUUID()
@RelationId((it: ProductReview) => it.product)
@ColumnIndex()
@MultiORMColumn({ relationId: true })
productId?: ID;

/**
* User`s who have reviewed the product
*/
@MultiORMManyToOne(() => User, {
/** Database cascade action on delete. */
onDelete: 'CASCADE'
})
@JoinColumn()
user?: IUser;

@ApiProperty({ type: () => String })
@IsUUID()
@RelationId((it: ProductReview) => it.user)
@ColumnIndex()
@MultiORMColumn({ relationId: true })
userId?: ID;
}
23 changes: 23 additions & 0 deletions packages/plugins/product-reviews/src/lib/product-review.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IBasePerTenantAndOrganizationEntityModel, ID, IProduct, IUser } from '@gauzy/contracts';

export type ProductReviewStatus = 'approved' | 'pending' | 'rejected';

// Enum for product review status
export enum ProductReviewStatusEnum {
APPROVED = 'approved',
PENDING = 'pending',
REJECTED = 'rejected'
}

export interface IProductReview extends IBasePerTenantAndOrganizationEntityModel {
title: string;
description: string;
rating: number;
upvotes: number;
downvotes: number;
status: ProductReviewStatus;
product?: IProduct;
productId?: ID;
user?: IUser;
userId?: ID;
}
Loading