-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
31 changed files
with
5,087 additions
and
4,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/api/src/app/activity/usecases/upload-history/upload-history.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IsDefined, IsMongoId, IsOptional, IsString } from 'class-validator'; | ||
import { PaginationCommand } from '@shared/commands/pagination.command'; | ||
|
||
export class UploadHistoryCommand extends PaginationCommand { | ||
@IsDefined() | ||
@IsMongoId() | ||
_projectId: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
name?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
date?: string; | ||
} |
9 changes: 2 additions & 7 deletions
9
apps/api/src/app/activity/usecases/upload-history/upload-history.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { IsDefined, IsNumber, IsString } from 'class-validator'; | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
|
||
export class ImportListResponseDto { | ||
@ApiPropertyOptional({ | ||
description: 'Id of the import', | ||
}) | ||
@IsString() | ||
@IsDefined() | ||
_id?: string; | ||
|
||
@ApiProperty({ | ||
description: 'Name of the import', | ||
}) | ||
@IsString() | ||
@IsDefined() | ||
name: string; | ||
|
||
@ApiProperty({ | ||
description: 'Total number of uploads', | ||
}) | ||
@IsNumber() | ||
@IsDefined() | ||
totalUploads: number; | ||
|
||
@ApiProperty({ | ||
description: 'Total number of records imported', | ||
}) | ||
@IsNumber() | ||
@IsDefined() | ||
totalRecords: number; | ||
|
||
@ApiProperty({ | ||
description: 'Total number of invalid records', | ||
}) | ||
@IsNumber() | ||
@IsDefined() | ||
totalInvalidRecords: number; | ||
} |
32 changes: 32 additions & 0 deletions
32
apps/api/src/app/project/dtos/template-list-response.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IsDefined, IsNumber, IsString } from 'class-validator'; | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
|
||
export class TemplateListResponseDto { | ||
@ApiPropertyOptional({ | ||
description: 'Id of the template', | ||
}) | ||
@IsString() | ||
@IsDefined() | ||
_id?: string; | ||
|
||
@ApiProperty({ | ||
description: 'Name of the template', | ||
}) | ||
@IsString() | ||
@IsDefined() | ||
name: string; | ||
|
||
@ApiProperty({ | ||
description: 'URL to download samle csv file', | ||
}) | ||
@IsString() | ||
@IsDefined() | ||
sampleFileUrl: string; | ||
|
||
@ApiProperty({ | ||
description: 'Total number of columns in the template', | ||
}) | ||
@IsDefined() | ||
@IsNumber() | ||
totalColumns: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apps/api/src/app/project/usecases/get-imports/get-imports.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { IsDefined, IsString } from 'class-validator'; | ||
import { PaginationCommand } from '@shared/commands/pagination.command'; | ||
|
||
export class GetImportsCommand extends PaginationCommand { | ||
@IsDefined() | ||
@IsString() | ||
_projectId: string; | ||
} |
40 changes: 40 additions & 0 deletions
40
apps/api/src/app/project/usecases/get-imports/get-imports.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { GetImportsCommand } from './get-imports.command'; | ||
import { TemplateRepository, CommonRepository } from '@impler/dal'; | ||
import { ImportListResponseDto } from 'app/project/dtos/import-list-response.dto'; | ||
import { PaginationResult } from '@impler/shared'; | ||
|
||
@Injectable() | ||
export class GetImports { | ||
constructor(private templateRepository: TemplateRepository, private commonRepository: CommonRepository) {} | ||
|
||
async execute({ | ||
_projectId, | ||
limit, | ||
page, | ||
search, | ||
}: GetImportsCommand): Promise<PaginationResult<ImportListResponseDto>> { | ||
const imports = await this.templateRepository.paginate( | ||
{ | ||
_projectId: this.commonRepository.generateMongoId(_projectId), | ||
name: { | ||
$regex: search || '', | ||
$options: 'i', | ||
}, | ||
}, | ||
'name totalUploads totalRecords totalInvalidRecords', | ||
{ | ||
skip: limit * (page - 1), | ||
limit, | ||
} | ||
); | ||
|
||
return { | ||
page, | ||
limit, | ||
data: imports.data, | ||
totalPages: Math.ceil(imports.total / limit), | ||
totalRecords: imports.total, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IsNumber, IsOptional, IsString } from 'class-validator'; | ||
import { BaseCommand } from './base.command'; | ||
|
||
export class PaginationCommand extends BaseCommand { | ||
@IsOptional() | ||
@IsNumber() | ||
page?: number; | ||
|
||
@IsOptional() | ||
@IsNumber() | ||
limit?: number; | ||
|
||
@IsOptional() | ||
@IsString() | ||
search?: string; | ||
} |
Oops, something went wrong.