Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

refactoring

kruzhambusf7ab24b53a52
diff --git a/src/project/dto/delete-partially.dto.ts b/src/project/dto/delete-partially.dto.ts
deleted file mode 100644
index 27ccd1113..000000000
--- a/src/project/dto/delete-partially.dto.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { ApiProperty } from '@nestjs/swagger'
-import { IsNotEmpty } from 'class-validator'
-
-export class PartialDeleteDTO {
- @ApiProperty({
- example: 'STEzHcB1rALV',
- required: true,
- description: 'The project ID you want to partially delete data for',
- })
- @IsNotEmpty()
- pid: string
-
- @ApiProperty()
- @IsNotEmpty()
- from: string
-
- @ApiProperty()
- @IsNotEmpty()
- to: string
-}
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index 6b5a4c7ee..1acd88c66 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -43,7 +43,6 @@ import { UserService } from '../user/user.service'
import { ProjectDTO } from './dto/project.dto'
import { ShareDTO } from './dto/share.dto'
import { ShareUpdateDTO } from './dto/share-update.dto'
-import { PartialDeleteDTO } from './dto/delete-partially.dto'
import { isValidDate } from 'src/analytics/analytics.service'
import { AppLoggerService } from '../logger/logger.service'
import {
@@ -550,20 +549,21 @@ export class ProjectController {
}
}
- @Delete('/partially/:id')
+ @Delete('/partially/:pid')
+ @ApiQuery({ name: 'from', required: true, description: 'Date in ISO format', example: '2020-01-01T00:00:00.000Z', type: 'string' })
+ @ApiQuery({ name: 'to', required: true, description: 'Date in ISO format', example: '2020-01-01T00:00:00.000Z', type: 'string' })
@ApiResponse({ status: 201 })
@UseGuards(JwtAccessTokenGuard, RolesGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
async deletePartially(
- @Body() deleteDTO: PartialDeleteDTO,
- @Param('id') id: string,
+ @Param('pid') pid: string,
+ @Query('from') from: string,
+ @Query('to') to: string,
@CurrentUserId() uid: string,
): Promise<any> {
- this.logger.log({ deleteDTO, uid }, 'DELETE /partially/:id')
-
- let { from, to } = deleteDTO
+ this.logger.log({ from, to, pid }, 'DELETE /partially/:id')
- if (!isValidPID(id)) {
+ if (!isValidPID(pid)) {
throw new BadRequestException('The provided Project ID (pid) is incorrect')
}
@@ -581,7 +581,7 @@ export class ProjectController {
from = dayjs(from).format('YYYY-MM-DD')
to = dayjs(to).format('YYYY-MM-DD 23:59:59')
- const project = await this.projectService.findOne(id, {
+ const project = await this.projectService.findOne(pid, {
relations: ['admin', 'share'],
})
@@ -596,7 +596,7 @@ export class ProjectController {
const queryP = 'ALTER TABLE performance DELETE WHERE pid = {pid:FixedString(12)} AND created BETWEEN {from:String} AND {to:String}'
const params = {
params: {
- id, from, to,
+ pid, from, to,
},
}