Skip to content

PM-1304 - add audit trail when description gets updated #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/api/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class AdminService {
}
: undefined,
},
include: {
winnings: true,
},
});
}

Expand Down Expand Up @@ -119,6 +122,18 @@ export class AdminService {
},
}),
);

if (payment.installment_number === 1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium
performance
Consider checking if body.description is different from payment.winnings.description before adding an audit entry. This will prevent unnecessary audit entries when the description hasn't actually changed.

transactions.push((tx) =>
this.addAudit(
userId,
winningsId,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high
correctness
Ensure that winningsId and userId are correctly defined and available in this context. If they are undefined or incorrect, it could lead to incorrect audit trail entries.

`Modified payment description from "${payment.winnings.description}" to "${body.description}"`,
body.auditNote,
tx,
),
);
}
}

let paymentStatus = payment.payment_status as PaymentStatus;
Expand Down Expand Up @@ -546,6 +561,7 @@ export class AdminService {
},
},
take: 1000,
orderBy: { created_at: 'desc' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium
performance
Ensure that the created_at field is indexed in the database to optimize the performance of the orderBy operation, especially since the query takes up to 1000 records.

});

result.data = audits.map((item) => ({
Expand Down