feat: add filter data scheduling date #179
|
@ -12,6 +12,7 @@ import { DataSchedulingReadOrchestrator } from './domain/usecases/data-schedulin
|
|||
import {
|
||||
DataSchedulingDataController,
|
||||
DataSchedulingDefaultController,
|
||||
DataSchedulingDataLogController,
|
||||
DataSchedulingSetupController,
|
||||
} from './infrastructure/data-scheduling-data.controller';
|
||||
import { DataSchedulingDataOrchestrator } from './domain/usecases/data-scheduling-data.orchestrator';
|
||||
|
@ -66,6 +67,7 @@ import { IndexDataSchedulingLogManager } from './domain/usecases/managers/index-
|
|||
DataSchedulingDefaultController,
|
||||
DataSchedulingSetupController,
|
||||
DataSchedulingLogReadController,
|
||||
DataSchedulingDataLogController,
|
||||
],
|
||||
providers: [
|
||||
SetupSchedulingGuard,
|
||||
|
@ -86,6 +88,7 @@ import { IndexDataSchedulingLogManager } from './domain/usecases/managers/index-
|
|||
DataSchedulingLogReadService,
|
||||
DataSchedulingDataService,
|
||||
DataSchedulingReadService,
|
||||
DataSchedulingLogDataService,
|
||||
|
||||
DataSchedulingDataOrchestrator,
|
||||
DataSchedulingReadOrchestrator,
|
||||
|
|
|
@ -3,6 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { DataSchedulingLogModel } from '../models/data-scheduling-log.model';
|
||||
import { Repository } from 'typeorm';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class DataSchedulingLogDataService {
|
||||
|
@ -14,4 +15,19 @@ export class DataSchedulingLogDataService {
|
|||
async create(entity: any): Promise<any> {
|
||||
return await this.repo.save(entity);
|
||||
}
|
||||
|
||||
async deleteRange(from: number, to: number): Promise<any> {
|
||||
try {
|
||||
const deleteResult = await this.repo
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(TABLE_NAME.DATA_SCHEDULING_LOG)
|
||||
.where('log_created_at BETWEEN :from AND :to', { from, to })
|
||||
.execute();
|
||||
|
||||
return deleteResult;
|
||||
} catch (error) {
|
||||
throw new Error('Failed to delete range due to an internal error.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,8 +119,8 @@ export class DataSchedulingUpdatedHandler
|
|||
const editorName = newData.editor_name || 'System';
|
||||
const itemName = oldData?.name || 'an item';
|
||||
|
||||
const totalPercentageOld = decryptionTotal(oldData?.indexing_key);
|
||||
const totalPercentageNew = decryptionTotal(newData?.indexing_key);
|
||||
const totalPercentageOld = oldData?.indexing_key;
|
||||
const totalPercentageNew = newData?.indexing_key;
|
||||
const isTotalSame = totalPercentageOld === totalPercentageNew;
|
||||
const labelName = `${
|
||||
isTotalSame
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
CreateDataSchedulingDto,
|
||||
EditDataSchedulingDto,
|
||||
EditDataSchedulingDefaultDto,
|
||||
DeleteDataSchedulingLogDto,
|
||||
} from './dto/data-scheduling.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
|
@ -26,6 +27,7 @@ import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto'
|
|||
import { ExcludePrivilege, Public } from 'src/core/guards';
|
||||
import { SetupSchedulingGuard } from './guards/setup-scheduling.guard';
|
||||
import { DataSchedulingManager } from '../domain/usecases/managers/data-scheduling-default.manager';
|
||||
import { DataSchedulingLogDataService } from '../data/services/data-scheduling-log-data.service';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.DATA_SCHEDULING.split('-').join(' ')} - data`)
|
||||
@Controller(`v1/${MODULE_NAME.DATA_SCHEDULING}`)
|
||||
|
@ -127,3 +129,20 @@ export class DataSchedulingSetupController {
|
|||
return this.manager.setupActiveScheduling();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiTags(`${MODULE_NAME.DATA_SCHEDULING_LOG.split('-').join(' ')} log - Data`)
|
||||
@Controller(`v1/${MODULE_NAME.DATA_SCHEDULING_LOG}`)
|
||||
@Public(true)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class DataSchedulingDataLogController {
|
||||
constructor(private service: DataSchedulingLogDataService) {}
|
||||
|
||||
@Post('delete-range')
|
||||
@ExcludePrivilege()
|
||||
@UseGuards(SetupSchedulingGuard)
|
||||
async setup(
|
||||
@Body() data: DeleteDataSchedulingLogDto,
|
||||
): Promise<{ message: string }> {
|
||||
return this.service.deleteRange(data.log_created_from, data.log_created_to);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,3 +86,13 @@ export class SetupDataSchedulingDto {
|
|||
// @ApiProperty({ type: 'string', required: true, example: '2025-01-01' })
|
||||
// date: Date;
|
||||
}
|
||||
|
||||
export class DeleteDataSchedulingLogDto {
|
||||
@ApiProperty({ type: Number, required: true })
|
||||
@ValidateIf((body) => body.log_created_from)
|
||||
log_created_from: number;
|
||||
|
||||
@ApiProperty({ type: Number, required: true })
|
||||
@ValidateIf((body) => body.log_created_to)
|
||||
log_created_to: number;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue