feat: update text desc scheduling loh

pull/177/head
Firman Ramdhani 2025-07-11 11:19:11 +07:00
parent dc0dbf6ad3
commit 0e8256bee7
3 changed files with 17 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import {
} from '../../entities/data-scheduling.entity'; } from '../../entities/data-scheduling.entity';
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import { DataSchedulingLogDataService } from '../../../data/services/data-scheduling-log-data.service'; import { DataSchedulingLogDataService } from '../../../data/services/data-scheduling-log-data.service';
import { decryptionTotal } from '../../../infrastructure/helpers';
@EventsHandler(DataSchedulingChangeStatusEvent) @EventsHandler(DataSchedulingChangeStatusEvent)
export class DataSchedulingChangeStatusHandler export class DataSchedulingChangeStatusHandler
@ -28,7 +29,9 @@ export class DataSchedulingChangeStatusHandler
const scheduleName = newData?.name || 'an item'; const scheduleName = newData?.name || 'an item';
const editorName = newData.editor_name || 'System'; const editorName = newData.editor_name || 'System';
const description = `<div><b>${editorName}</b> changed the status of <b><i>${scheduleName}</i></b> from <b><i>${oldStatus}</i></b> to <b><i>${newStatus}</i></b>.</div>`; const totalPercentage = decryptionTotal(newData?.indexing_key);
const description = `<div><b>${editorName}</b> changed the status of <b><i>${scheduleName} (${totalPercentage}%)</i></b> from <b><i>${oldStatus}</i></b> to <b><i>${newStatus}</i></b>.</div>`;
const payload: DataSchedulingLogEntity = { const payload: DataSchedulingLogEntity = {
type: SCHEDULING_LOG_TYPE_ENUM.DATA_SCHEDULING, type: SCHEDULING_LOG_TYPE_ENUM.DATA_SCHEDULING,

View File

@ -7,6 +7,7 @@ import {
} from '../../entities/data-scheduling.entity'; } from '../../entities/data-scheduling.entity';
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import { DataSchedulingLogDataService } from '../../../data/services/data-scheduling-log-data.service'; import { DataSchedulingLogDataService } from '../../../data/services/data-scheduling-log-data.service';
import { decryptionTotal } from '../../../infrastructure/helpers';
@EventsHandler(DataSchedulingDeletedEvent) @EventsHandler(DataSchedulingDeletedEvent)
export class DataSchedulingDeletedHandler export class DataSchedulingDeletedHandler
@ -27,8 +28,8 @@ export class DataSchedulingDeletedHandler
'System'; 'System';
const scheduleName = deletedData?.name || 'an item'; const scheduleName = deletedData?.name || 'an item';
const totalPercentage = decryptionTotal(deletedData?.indexing_key);
const description = `<div><b>${deleterName}</b> deleted schedule: <b><i>${scheduleName}</i></b>.</div>`; const description = `<div><b>${deleterName}</b> deleted schedule: <b><i>${scheduleName} (${totalPercentage}%)</i></b>.</div>`;
const payload: DataSchedulingLogEntity = { const payload: DataSchedulingLogEntity = {
type: SCHEDULING_LOG_TYPE_ENUM.DATA_SCHEDULING, type: SCHEDULING_LOG_TYPE_ENUM.DATA_SCHEDULING,

View File

@ -119,7 +119,16 @@ export class DataSchedulingUpdatedHandler
const editorName = newData.editor_name || 'System'; const editorName = newData.editor_name || 'System';
const itemName = oldData?.name || 'an item'; const itemName = oldData?.name || 'an item';
let description = `<div><b>${editorName}</b> has updated schedule for <b><i>${itemName}</i></b>.`; const totalPercentageOld = decryptionTotal(oldData?.indexing_key);
const totalPercentageNew = decryptionTotal(newData?.indexing_key);
const isTotalSame = totalPercentageOld === totalPercentageNew;
const labelName = `${
isTotalSame
? `${totalPercentageNew}%`
: `${totalPercentageOld}% to ${totalPercentageNew}%`
}`;
let description = `<div><b>${editorName}</b> has updated schedule for <b><i>${itemName} (${labelName})</i></b>.`;
if (Object.keys(changingData.old).length > 0) { if (Object.keys(changingData.old).length > 0) {
description += ` Change details:<ul>`; description += ` Change details:<ul>`;