Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#8190-global-stats-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket committed Sep 12, 2024
2 parents 89dfdf7 + 24394a8 commit a9a5101
Show file tree
Hide file tree
Showing 25 changed files with 659 additions and 2 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"typeORM",
"Fargate",
"fastify",
"favoritable",
"fbstate",
"fieldname",
"filepond",
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/employee.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ICandidate } from './candidate.model';
import { IEmployeeAward } from './employee-award.model';
import { IOrganizationProjectModule } from './organization-project-module.model';
import { CurrenciesEnum } from './currency.model';
import { IFavorite } from './favorite.model';

export interface IFindMembersInput extends IBasePerTenantAndOrganizationEntityModel {
organizationTeamId: ID;
Expand Down Expand Up @@ -64,6 +65,7 @@ export interface IEmployee extends IBasePerTenantAndOrganizationEntityModel, ITa
organizationPosition?: IOrganizationPosition;
skills?: ISkill[];
awards?: IEmployeeAward[];
favorites?: IFavorite[];
offerDate?: Date;
acceptDate?: Date;
rejectDate?: Date;
Expand Down
20 changes: 20 additions & 0 deletions packages/contracts/src/favorite.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { IBasePerTenantAndOrganizationEntityModel, ID } from './base-entity.model';
import { IEmployeeEntityInput } from './employee.model';

export interface IFavorite extends IBasePerTenantAndOrganizationEntityModel, IEmployeeEntityInput {
entity: FavoriteEntityEnum;
entityId: ID; // Indicate the ID of entity record marked as favorite
}

export enum FavoriteEntityEnum {
Organization = 'Organization',
OrganizationProject = 'OrganizationProject',
OrganizationTeam = 'OrganizationTeam',
OrganizationProjectModule = 'OrganizationProjectModule',
Currency = 'Currency',
Language = 'Language',
OrganizationVendor = 'OrganizationVendor',
OrganizationSprint = 'OrganizationSprint'
}

export interface IFavoriteCreateInput extends IFavorite {}
1 change: 1 addition & 0 deletions packages/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export * from './event-type.model';
export * from './expense-category.model';
export * from './expense-category.model';
export * from './expense.model';
export * from './favorite.model';
export * from './feature.model';
export * from './file-provider';
export * from './geo-location.model';
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ import { TaskEstimationModule } from './tasks/estimation/task-estimation.module'
import { DailyPlanModule } from './tasks/daily-plan/daily-plan.module';
import { SocialAccountModule } from './auth/social-account/social-account.module';
import { OrganizationProjectModuleModule } from './organization-project-module/organization-project-module.module';
import { FavoriteModule } from './favorite/favorite.module';
import { GlobalFavoriteModule } from './favorite/global-favorite-service.module';
import { StatsModule } from './stats/stats.module'; // Global Stats Module

const { unleashConfig } = environment;
Expand Down Expand Up @@ -435,6 +437,8 @@ if (environment.THROTTLE_ENABLED) {
TaskLinkedIssueModule,
OrganizationTaskSettingModule,
TaskEstimationModule,
FavoriteModule,
GlobalFavoriteModule,
StatsModule // Global Stats Module
],
controllers: [AppController],
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './is-secret';
export * from './is-favoritable';
export * from './entity';
7 changes: 7 additions & 0 deletions packages/core/src/core/decorators/is-favoritable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FavoriteEntityEnum } from '@gauzy/contracts';
import { SetMetadata } from '@nestjs/common';

export const FAVORITE_SERVICE = 'FAVORITE_SERVICE';
export const FAVORITABLE_TYPE = 'favoriteEntity';

export const FavoriteService = (type: FavoriteEntityEnum) => SetMetadata(FAVORITABLE_TYPE, type);
2 changes: 2 additions & 0 deletions packages/core/src/core/entities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
EventType,
Expense,
ExpenseCategory,
Favorite,
Feature,
FeatureOrganization,
Goal,
Expand Down Expand Up @@ -178,6 +179,7 @@ export const coreEntities = [
EventType,
Expense,
ExpenseCategory,
Favorite,
Feature,
FeatureOrganization,
Goal,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core/entities/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export * from '../../expense-categories/expense-category.entity';
export * from '../../expense/expense.entity';
export * from '../../export-import/import-history/import-history.entity';
export * from '../../export-import/import-record/import-record.entity';
export * from '../../favorite/favorite.entity';
export * from '../../feature/feature-organization.entity';
export * from '../../feature/feature.entity';
export * from '../../goal-general-setting/goal-general-setting.entity';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { yellow } from 'chalk';
import { DatabaseTypeEnum } from '@gauzy/config';

export class AddFavoriteTable1725950092620 implements MigrationInterface {
name = 'AddFavoriteTable1725950092620';

/**
* Up Migration
*
* @param queryRunner
*/
public async up(queryRunner: QueryRunner): Promise<void> {
console.log(yellow(this.name + ' start running!'));

switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlUpQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* Down Migration
*
* @param queryRunner
*/
public async down(queryRunner: QueryRunner): Promise<void> {
switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlDownQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* PostgresDB Up Migration
*
* @param queryRunner
*/
public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE "favorite" ("deletedAt" TIMESTAMP, "id" uuid NOT NULL DEFAULT gen_random_uuid(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "isActive" boolean DEFAULT true, "isArchived" boolean DEFAULT false, "archivedAt" TIMESTAMP, "tenantId" uuid, "organizationId" uuid, "entity" character varying NOT NULL, "entityId" character varying NOT NULL, "employeeId" uuid, CONSTRAINT "PK_495675cec4fb09666704e4f610f" PRIMARY KEY ("id"))`
);
await queryRunner.query(`CREATE INDEX "IDX_8ab4c215a9b90395ce242d7cac" ON "favorite" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_aac7859c7c93073a7fd990ab66" ON "favorite" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_fd7fbcabed207b9f7398802738" ON "favorite" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_7e0f07d02bea087f84f271e9bf" ON "favorite" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_a8d924902879f0a3349678c86f" ON "favorite" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_b4734abeedbb9c724c980f7f54" ON "favorite" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17" ON "favorite" ("employeeId") `);
await queryRunner.query(
`ALTER TABLE "favorite" ADD CONSTRAINT "FK_fd7fbcabed207b9f7398802738e" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE "favorite" ADD CONSTRAINT "FK_7e0f07d02bea087f84f271e9bf4" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE "favorite" ADD CONSTRAINT "FK_59e3dbf9b24f9d1cb7534dbf177" FOREIGN KEY ("employeeId") REFERENCES "employee"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}

/**
* PostgresDB Down Migration
*
* @param queryRunner
*/
public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "favorite" DROP CONSTRAINT "FK_59e3dbf9b24f9d1cb7534dbf177"`);
await queryRunner.query(`ALTER TABLE "favorite" DROP CONSTRAINT "FK_7e0f07d02bea087f84f271e9bf4"`);
await queryRunner.query(`ALTER TABLE "favorite" DROP CONSTRAINT "FK_fd7fbcabed207b9f7398802738e"`);
await queryRunner.query(`DROP INDEX "public"."IDX_59e3dbf9b24f9d1cb7534dbf17"`);
await queryRunner.query(`DROP INDEX "public"."IDX_b4734abeedbb9c724c980f7f54"`);
await queryRunner.query(`DROP INDEX "public"."IDX_a8d924902879f0a3349678c86f"`);
await queryRunner.query(`DROP INDEX "public"."IDX_7e0f07d02bea087f84f271e9bf"`);
await queryRunner.query(`DROP INDEX "public"."IDX_fd7fbcabed207b9f7398802738"`);
await queryRunner.query(`DROP INDEX "public"."IDX_aac7859c7c93073a7fd990ab66"`);
await queryRunner.query(`DROP INDEX "public"."IDX_8ab4c215a9b90395ce242d7cac"`);
await queryRunner.query(`DROP TABLE "favorite"`);
}

/**
* SqliteDB and BetterSQlite3DB Up Migration
*
* @param queryRunner
*/
public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE "favorite" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "employeeId" varchar)`
);
await queryRunner.query(`CREATE INDEX "IDX_8ab4c215a9b90395ce242d7cac" ON "favorite" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_aac7859c7c93073a7fd990ab66" ON "favorite" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_fd7fbcabed207b9f7398802738" ON "favorite" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_7e0f07d02bea087f84f271e9bf" ON "favorite" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_a8d924902879f0a3349678c86f" ON "favorite" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_b4734abeedbb9c724c980f7f54" ON "favorite" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17" ON "favorite" ("employeeId") `);
await queryRunner.query(`DROP INDEX "IDX_8ab4c215a9b90395ce242d7cac"`);
await queryRunner.query(`DROP INDEX "IDX_aac7859c7c93073a7fd990ab66"`);
await queryRunner.query(`DROP INDEX "IDX_fd7fbcabed207b9f7398802738"`);
await queryRunner.query(`DROP INDEX "IDX_7e0f07d02bea087f84f271e9bf"`);
await queryRunner.query(`DROP INDEX "IDX_a8d924902879f0a3349678c86f"`);
await queryRunner.query(`DROP INDEX "IDX_b4734abeedbb9c724c980f7f54"`);
await queryRunner.query(`DROP INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17"`);
await queryRunner.query(
`CREATE TABLE "temporary_favorite" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "employeeId" varchar, CONSTRAINT "FK_fd7fbcabed207b9f7398802738e" FOREIGN KEY ("tenantId") REFERENCES "tenant" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_7e0f07d02bea087f84f271e9bf4" FOREIGN KEY ("organizationId") REFERENCES "organization" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "FK_59e3dbf9b24f9d1cb7534dbf177" FOREIGN KEY ("employeeId") REFERENCES "employee" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_favorite"("deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "employeeId") SELECT "deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "employeeId" FROM "favorite"`
);
await queryRunner.query(`DROP TABLE "favorite"`);
await queryRunner.query(`ALTER TABLE "temporary_favorite" RENAME TO "favorite"`);
await queryRunner.query(`CREATE INDEX "IDX_8ab4c215a9b90395ce242d7cac" ON "favorite" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_aac7859c7c93073a7fd990ab66" ON "favorite" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_fd7fbcabed207b9f7398802738" ON "favorite" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_7e0f07d02bea087f84f271e9bf" ON "favorite" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_a8d924902879f0a3349678c86f" ON "favorite" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_b4734abeedbb9c724c980f7f54" ON "favorite" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17" ON "favorite" ("employeeId") `);
}

/**
* SqliteDB and BetterSQlite3DB Down Migration
*
* @param queryRunner
*/
public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`DROP INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17"`);
await queryRunner.query(`DROP INDEX "IDX_b4734abeedbb9c724c980f7f54"`);
await queryRunner.query(`DROP INDEX "IDX_a8d924902879f0a3349678c86f"`);
await queryRunner.query(`DROP INDEX "IDX_7e0f07d02bea087f84f271e9bf"`);
await queryRunner.query(`DROP INDEX "IDX_fd7fbcabed207b9f7398802738"`);
await queryRunner.query(`DROP INDEX "IDX_aac7859c7c93073a7fd990ab66"`);
await queryRunner.query(`DROP INDEX "IDX_8ab4c215a9b90395ce242d7cac"`);
await queryRunner.query(`ALTER TABLE "favorite" RENAME TO "temporary_favorite"`);
await queryRunner.query(
`CREATE TABLE "favorite" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "employeeId" varchar)`
);
await queryRunner.query(
`INSERT INTO "favorite"("deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "employeeId") SELECT "deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "employeeId" FROM "temporary_favorite"`
);
await queryRunner.query(`DROP TABLE "temporary_favorite"`);
await queryRunner.query(`CREATE INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17" ON "favorite" ("employeeId") `);
await queryRunner.query(`CREATE INDEX "IDX_b4734abeedbb9c724c980f7f54" ON "favorite" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_a8d924902879f0a3349678c86f" ON "favorite" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_7e0f07d02bea087f84f271e9bf" ON "favorite" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_fd7fbcabed207b9f7398802738" ON "favorite" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_aac7859c7c93073a7fd990ab66" ON "favorite" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_8ab4c215a9b90395ce242d7cac" ON "favorite" ("isActive") `);
await queryRunner.query(`DROP INDEX "IDX_59e3dbf9b24f9d1cb7534dbf17"`);
await queryRunner.query(`DROP INDEX "IDX_b4734abeedbb9c724c980f7f54"`);
await queryRunner.query(`DROP INDEX "IDX_a8d924902879f0a3349678c86f"`);
await queryRunner.query(`DROP INDEX "IDX_7e0f07d02bea087f84f271e9bf"`);
await queryRunner.query(`DROP INDEX "IDX_fd7fbcabed207b9f7398802738"`);
await queryRunner.query(`DROP INDEX "IDX_aac7859c7c93073a7fd990ab66"`);
await queryRunner.query(`DROP INDEX "IDX_8ab4c215a9b90395ce242d7cac"`);
await queryRunner.query(`DROP TABLE "favorite"`);
}

/**
* MySQL Up Migration
*
* @param queryRunner
*/
public async mysqlUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE \`favorite\` (\`deletedAt\` datetime(6) NULL, \`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updatedAt\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`isActive\` tinyint NULL DEFAULT 1, \`isArchived\` tinyint NULL DEFAULT 0, \`archivedAt\` datetime NULL, \`tenantId\` varchar(255) NULL, \`organizationId\` varchar(255) NULL, \`entity\` varchar(255) NOT NULL, \`entityId\` varchar(255) NOT NULL, \`employeeId\` varchar(255) NULL, INDEX \`IDX_8ab4c215a9b90395ce242d7cac\` (\`isActive\`), INDEX \`IDX_aac7859c7c93073a7fd990ab66\` (\`isArchived\`), INDEX \`IDX_fd7fbcabed207b9f7398802738\` (\`tenantId\`), INDEX \`IDX_7e0f07d02bea087f84f271e9bf\` (\`organizationId\`), INDEX \`IDX_a8d924902879f0a3349678c86f\` (\`entity\`), INDEX \`IDX_b4734abeedbb9c724c980f7f54\` (\`entityId\`), INDEX \`IDX_59e3dbf9b24f9d1cb7534dbf17\` (\`employeeId\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
);
await queryRunner.query(
`ALTER TABLE \`favorite\` ADD CONSTRAINT \`FK_fd7fbcabed207b9f7398802738e\` FOREIGN KEY (\`tenantId\`) REFERENCES \`tenant\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE \`favorite\` ADD CONSTRAINT \`FK_7e0f07d02bea087f84f271e9bf4\` FOREIGN KEY (\`organizationId\`) REFERENCES \`organization\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`favorite\` ADD CONSTRAINT \`FK_59e3dbf9b24f9d1cb7534dbf177\` FOREIGN KEY (\`employeeId\`) REFERENCES \`employee\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
);
}

/**
* MySQL Down Migration
*
* @param queryRunner
*/
public async mysqlDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE \`favorite\` DROP FOREIGN KEY \`FK_59e3dbf9b24f9d1cb7534dbf177\``);
await queryRunner.query(`ALTER TABLE \`favorite\` DROP FOREIGN KEY \`FK_7e0f07d02bea087f84f271e9bf4\``);
await queryRunner.query(`ALTER TABLE \`favorite\` DROP FOREIGN KEY \`FK_fd7fbcabed207b9f7398802738e\``);
await queryRunner.query(`DROP INDEX \`IDX_59e3dbf9b24f9d1cb7534dbf17\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_b4734abeedbb9c724c980f7f54\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_a8d924902879f0a3349678c86f\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_7e0f07d02bea087f84f271e9bf\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_fd7fbcabed207b9f7398802738\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_aac7859c7c93073a7fd990ab66\` ON \`favorite\``);
await queryRunner.query(`DROP INDEX \`IDX_8ab4c215a9b90395ce242d7cac\` ON \`favorite\``);
await queryRunner.query(`DROP TABLE \`favorite\``);
}
}
15 changes: 14 additions & 1 deletion packages/core/src/employee/employee.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {
IEmployeePhone,
IDailyPlan,
IOrganizationProjectModule,
ID
ID,
IFavorite
} from '@gauzy/contracts';
import {
ColumnIndex,
Expand All @@ -55,6 +56,7 @@ import {
EmployeeSetting,
EquipmentSharing,
Expense,
Favorite,
Goal,
InvoiceItem,
OrganizationContact,
Expand Down Expand Up @@ -560,11 +562,22 @@ export class Employee extends TenantOrganizationBaseEntity implements IEmployee,
@MultiORMOneToMany(() => EmployeePhone, (it) => it.employee)
phoneNumbers?: IEmployeePhone[];

/**
* Daily Plans
*/
@MultiORMOneToMany(() => DailyPlan, (dailyPlan) => dailyPlan.employee, {
cascade: true
})
dailyPlans?: IDailyPlan[];

/**
* Favorites entity records
*/
@MultiORMOneToMany(() => Favorite, (favorite) => favorite.employee, {
cascade: true
})
favorites?: IFavorite[];

/*
|--------------------------------------------------------------------------
| @ManyToMany
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/favorite/dto/create-favorite.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IntersectionType } from '@nestjs/swagger';
import { IFavoriteCreateInput } from '@gauzy/contracts';
import { TenantOrganizationBaseDTO } from './../../core/dto';
import { Favorite } from '../favorite.entity';

/*
* Make entity record as favorite
*/
export class CreateFavoriteDTO
extends IntersectionType(TenantOrganizationBaseDTO, Favorite)
implements IFavoriteCreateInput {}
1 change: 1 addition & 0 deletions packages/core/src/favorite/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './create-favorite.dto';
Loading

0 comments on commit a9a5101

Please sign in to comment.