Skip to content

Commit

Permalink
Integration of coderabbitai's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmbabhazi committed Nov 18, 2024
1 parent 9d55f58 commit 2996d26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/shared/dto/selectors-query.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsOptional, IsArray, IsString } from 'class-validator';
import { IsOptional, IsArray } from 'class-validator';
import { ID, ITimeLogFilters, TimesheetStatus } from '@gauzy/contracts';
import { DateRangeQueryDTO } from './date-range-query.dto';

Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/time-tracking/timesheet/timesheet.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Between, In, SelectQueryBuilder, Brackets, WhereExpressionBuilder } from 'typeorm';
import * as moment from 'moment';
import { IGetTimesheetInput, PermissionsEnum, ITimesheet } from '@gauzy/contracts';
import { IGetTimesheetInput, PermissionsEnum, ITimesheet, TimesheetStatus } from '@gauzy/contracts';
import { RequestContext } from './../../core/context';
import { TenantAwareCrudService } from './../../core/crud';
import { getDateRangeFormat } from './../../core/utils';
Expand Down Expand Up @@ -116,8 +116,12 @@ export class TimeSheetService extends TenantAwareCrudService<Timesheet> {
new Brackets((qb: WhereExpressionBuilder) => {
qb.where({
startedAt: Between(start, end),
...(status.length > 0 ? { status: In(status) } : {}),
...(taskIds.length > 0 ? { taskIds: In(taskIds) } : {}),
...(status.length > 0
? {
status: In(status.filter((s) => Object.values(TimesheetStatus).includes(s)))
}
: {}),
...(taskIds.length > 0 ? { taskId: In(taskIds) } : {}),
...(employeeIds.length > 0 ? { employeeId: In(employeeIds) } : {})
});
})
Expand Down

0 comments on commit 2996d26

Please sign in to comment.