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

Stage #8658

Merged
merged 8 commits into from
Dec 31, 2024
4 changes: 2 additions & 2 deletions packages/contracts/src/lib/proposal.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export enum ProposalStatusEnum {
export interface IProposalBase extends IBasePerTenantAndOrganizationEntityModel, ITaggable {
jobPostUrl?: string;
valueDate?: Date;
jobPostContent?: string;
proposalContent?: string;
jobPostContent: string;
proposalContent: string;
status?: ProposalStatusEnum;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export function getMigrationsConfig() {
const migrationsDir = path.resolve(
__dirname,
isElectron
? './../database/migrations/*.ts' // Only .ts if Electron
? './../database/migrations/*.js' // Only .ts if Electron
: './../database/migrations/*{.ts,.js}' // Otherwise .ts or .js
);
console.log('Migration migrationsDir: ->', migrationsDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import { FindMeQueryDTO } from "../../user/dto";
*/
export class FindMeUserOrganizationDTO extends IntersectionType(
PickType(FindMeQueryDTO, ['includeEmployee'] as const),
) { }
) {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Controller, HttpStatus, Get, Query, UseGuards, HttpCode, Delete, Param } from '@nestjs/common';
import { CommandBus } from '@nestjs/cqrs';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { parseToBoolean } from '@gauzy/common';
import { IUserOrganization, IPagination, ID } from '@gauzy/contracts';
import { CrudController, PaginationParams } from './../core/crud';
import { UUIDValidationPipe } from './../shared/pipes';
Expand Down Expand Up @@ -42,7 +43,7 @@ export class UserOrganizationController extends CrudController<UserOrganization>
@Query() params: PaginationParams<UserOrganization>,
@Query() query: FindMeUserOrganizationDTO
): Promise<IPagination<IUserOrganization>> {
return await this.userOrganizationService.findUserOrganizations(params, query.includeEmployee);
return await this.userOrganizationService.findUserOrganizations(params, parseToBoolean(query.includeEmployee));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,32 @@ export class UserOrganizationService extends TenantAwareCrudService<UserOrganiza

// Extract user IDs from the items array
const userIds = items
.filter((organization: IUserOrganization) => organization.user) // Filter out user organizations without a user object
.map((organization: IUserOrganization) => organization.user.id);
.filter((organization: IUserOrganization) => organization?.user) // Filter out user organizations without a user object
.map((organization: IUserOrganization) => organization?.user?.id) || [];

// Fetch all employee details in bulk for the extracted user IDs
const employees = await this.employeeService.findEmployeesByUserIds(userIds, tenantId);

// Map employee details to a dictionary for easier lookup
const employeeMap = new Map<string, Employee>();
employees.forEach((employee: Employee) => {
employeeMap.set(employee.userId, employee);
// If user ID is available, add employee details to the map
if (employee.userId) {
// Add employee details to the map
employeeMap.set(employee.userId, employee);
}
});

// Merge employee details into each user organization object
const itemsWithEmployees = items.map((organization: UserOrganization) => {
const employee = employeeMap.get(organization.user.id);
return { ...organization, user: { ...organization.user, employee } };
// If user ID is available, fetch employee details
if (organization.user.id) {
// Fetch employee details using the user ID
const employee = employeeMap.get(organization.user.id);
return { ...organization, user: { ...organization.user, employee } };
}
// If user ID is not available, return the original organization object
return { ...organization };
});

// Return paginated result with employee details
Expand Down
9 changes: 2 additions & 7 deletions packages/core/src/lib/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,9 @@ export class UserService extends TenantAwareCrudService<User> {

console.log('findMe found User with Id:', user.id);

// If 'includeEmployee' is set to true, fetch employee details associated with the user.
// Fetch employee details if 'includeEmployee' is true
if (options.includeEmployee) {
const relations: any = {};

// Include organization relation if 'includeOrganization' is true
if (options.includeOrganization) {
relations.organization = true;
}
const relations = options.includeOrganization ? { organization: true } : [];

employee = await this._employeeService.findOneByUserId(user.id, { relations });
}
Expand Down
25 changes: 0 additions & 25 deletions packages/plugins/integration-ai/.eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions packages/plugins/integration-ai/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const baseConfig = require('../../../.eslintrc.json');

module.exports = [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}']
}
]
},
languageOptions: {
parser: require('jsonc-eslint-parser')
}
}
];
1 change: 0 additions & 1 deletion packages/plugins/integration-ai/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
export default {
displayName: 'plugin-integration-ai',
preset: '../../../jest.preset.js',
Expand Down
5 changes: 2 additions & 3 deletions packages/plugins/integration-ai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitOverride": false,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": false
"noFallthroughCasesInSwitch": false,
"noPropertyAccessFromIndexSignature": false
},
"files": [],
"include": [],
Expand Down
25 changes: 0 additions & 25 deletions packages/plugins/job-proposal/.eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions packages/plugins/job-proposal/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const baseConfig = require('../../../.eslintrc.json');

module.exports = [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}']
}
]
},
languageOptions: {
parser: require('jsonc-eslint-parser')
}
}
];
1 change: 0 additions & 1 deletion packages/plugins/job-proposal/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
export default {
displayName: 'plugin-job-proposal',
preset: '../../../jest.preset.js',
Expand Down
18 changes: 18 additions & 0 deletions packages/plugins/job-proposal/src/lib/job-proposal.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@ import { EmployeeProposalTemplate } from './proposal-template/employee-proposal-
import { ProposalSeederService } from './proposal/proposal-seeder.service';

@Plugin({
/**
* An array of modules that will be imported and registered with the plugin.
*/
imports: [ProposalModule, EmployeeProposalTemplateModule],
/**
* An array of Entity classes. The plugin (or ORM) will
* register these entities for use within the application.
*/
entities: [Proposal, EmployeeProposalTemplate],
/**
* A callback that receives the main plugin configuration object and allows
* custom modifications before returning the final configuration.
*
* @param {ApplicationPluginConfig} config - The initial plugin configuration object.
* @returns {ApplicationPluginConfig} - The modified plugin configuration object.
*
* In this example, we're adding a custom relation field (`proposals`) to the `Tag` entity.
*/
configuration: (config: ApplicationPluginConfig) => {
// Add a new 'proposals' tag to the 'Tag' entity
config.customFields.Tag.push({
name: 'proposals',
type: 'relation',
Expand All @@ -21,6 +38,7 @@ import { ProposalSeederService } from './proposal/proposal-seeder.service';
entity: Proposal,
inverseSide: (it: Proposal) => it.tags
});

return config;
}
})
Expand Down
Loading
Loading