Skip to content

Commit

Permalink
fix: updated organization project module activity log
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket committed Feb 17, 2025
1 parent 128cc85 commit c128455
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { CommandHandlers } from './commands/handlers';
import { OrganizationProjectModuleService } from './organization-project-module.service';
import { OrganizationProjectModuleController } from './organization-project-module.controller';
import { OrganizationProjectModule } from './organization-project-module.entity';
import { TypeOrmOrganizationProjectModuleRepository } from './repository/type-orm-organization-project-module.repository';
import { RolePermissionModule } from '../role-permission/role-permission.module';
import { RoleModule } from '../role/role.module';
import { EmployeeModule } from '../employee/employee.module';
import { TaskModule } from '../tasks/task.module';
import { OrganizationProjectModuleEmployee } from './organization-project-module-employee.entity';
import { TypeOrmOrganizationProjectModuleRepository } from './repository/type-orm-organization-project-module.repository';
import { TypeOrmOrganizationProjectModuleEmployeeRepository } from './repository/type-orm-organization-project-module-employee.repository';
import { TaskModule } from '../tasks';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { isEmpty, isNotEmpty } from '@gauzy/utils';
import { isPostgres } from '@gauzy/config';
import { PaginationParams, TenantAwareCrudService } from './../core/crud';
import { RequestContext } from '../core/context';
import { RequestContext } from '../core/context/request-context';
import { OrganizationProjectModule } from './organization-project-module.entity';
import { prepareSQLQuery as p } from './../database/database.helper';
import { ActivityLogService } from '../activity-log/activity-log.service';
Expand All @@ -49,7 +49,7 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org
readonly mikroOrmProjectModuleRepository: MikroOrmOrganizationProjectModuleRepository,
readonly typeOrmOrganizationProjectModuleEmployeeRepository: TypeOrmOrganizationProjectModuleEmployeeRepository,
readonly mikroOrmOrganizationProjectModuleEmployeeRepository: MikroOrmOrganizationProjectModuleEmployeeRepository,
private readonly activityLogService: ActivityLogService,
private readonly _activityLogService: ActivityLogService,
private readonly _roleService: RoleService,
private readonly _employeeService: EmployeeService,
private readonly _taskService: TaskService
Expand All @@ -71,9 +71,13 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org

const { memberIds = [], managerIds = [], tasks = [], ...input } = entity;

// Add current employee to managerIds if applicable
await this.addCurrentEmployeeToManagers(managerIds, currentRoleId, employeeId);

// Retrieves a collection of employees based on specified criteria
const employeeIds = [...memberIds, ...managerIds].filter(Boolean);

// Retrieves a collection of employees based on specified criteria
const employees = await this._employeeService.findActiveEmployeesByEmployeeIds(
employeeIds,
organizationId,
Expand Down Expand Up @@ -516,20 +520,20 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org
options.select = params.select;
}

if (params.relations) {
options.relations = params.relations;
}

if (params.order) {
options.order = params.order;
}

if (params.relations) {
options.relations = params.relations;
}

// Apply pagination and query options
query.setFindOptions(options);
}
}

/**'
/**
* Apply optional filters to the query builder
*/
private applyOptionalFilters(
Expand Down Expand Up @@ -682,10 +686,10 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org
existingModule?: IOrganizationProjectModule,
changes?: Partial<IOrganizationProjectModuleUpdateInput>
): void {
const tenantId = RequestContext.currentTenantId();
const tenantId = RequestContext.currentTenantId() ?? updatedModule.tenantId;
const organizationId = updatedModule.organizationId;

this.activityLogService.logActivity<OrganizationProjectModule>(
this._activityLogService.logActivity<OrganizationProjectModule>(
BaseEntityEnum.OrganizationProjectModule,
action,
ActorTypeEnum.User,
Expand Down

0 comments on commit c128455

Please sign in to comment.