Skip to content

Commit

Permalink
Added filter options for taskId and TaskName
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Oberndörfer <[email protected]>
  • Loading branch information
flo0852 committed Dec 5, 2024
1 parent 0770c57 commit 8b1e629
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
17 changes: 15 additions & 2 deletions apps/backend/src/app/backupData/backupData.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BadRequestException, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import {
Between,
FindOptionsWhere,
ILike,
LessThanOrEqual,
MoreThanOrEqual,
Expand All @@ -21,7 +22,7 @@ import { BackupType } from './dto/backupType';
export class BackupDataService extends PaginationService {
constructor(
@InjectRepository(BackupDataEntity)
private backupDataRepository: Repository<BackupDataEntity>
private readonly backupDataRepository: Repository<BackupDataEntity>
) {
super();
}
Expand Down Expand Up @@ -79,7 +80,7 @@ export class BackupDataService extends PaginationService {
* @param backupDataFilterDto
*/
createWhereClause(backupDataFilterDto: BackupDataFilterDto) {
let where: any = {};
const where: FindOptionsWhere<BackupDataEntity> = {};

//ID search
if (backupDataFilterDto.id) {
Expand Down Expand Up @@ -138,6 +139,18 @@ export class BackupDataService extends PaginationService {
where.sizeMB = LessThanOrEqual(backupDataFilterDto.toSizeMB);
}

//Task id search
if (backupDataFilterDto.taskId) {
where.taskId = { id: backupDataFilterDto.taskId };
}

//Task name search
if (backupDataFilterDto.taskName) {
where.taskId = {
displayName: ILike(`%${backupDataFilterDto.taskName}%`),
};
}

where.type = BackupType.FULL;

return where;
Expand Down
16 changes: 15 additions & 1 deletion apps/backend/src/app/backupData/dto/backupDataFilter.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsDate, IsInt, IsOptional, IsString } from 'class-validator';
import { IsOptional, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class BackupDataFilterDto {
Expand Down Expand Up @@ -39,4 +39,18 @@ export class BackupDataFilterDto {
})
@IsOptional()
toSizeMB?: number;

@ApiProperty({
description: 'Task id',
required: false,
})
@IsOptional()
taskId?: string;

@ApiProperty({
description: 'Task name',
required: false,
})
@IsOptional()
taskName?: string;
}

0 comments on commit 8b1e629

Please sign in to comment.