Skip to content

Feat: audit log for status changes - #185

Merged
mozsarmate merged 4 commits into
mainfrom
feat/audit-log
Sep 14, 2026
Merged

mozsarmate merged 4 commits into
mainfrom
feat/audit-log

Conversation

@mozsarmate

Copy link
Copy Markdown
Contributor

Added audit logs to make application status changes traceble. See more info in the git log of the commits.

image

@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
schbody-frontend Ready Ready Preview Sep 14, 2026 3:35pm UTC

Request Review

@mozsarmate mozsarmate changed the title Feat/audit log Feat: audit log for status changes Sep 7, 2026
Add an ApplicationStatusLog table that records every application status
transition: timestamp, acting user and previous/new status. All status
changes now go through a single helper that writes the log entry and
refreshes the application's updatedAt.

- new ApplicationStatusLog model + migration
- applyStatusChange() centralises the status update and audit write
- thread the acting user through the manual PATCH and the profile
  picture side effects; system-initiated changes are logged with a
  null user
- GET /application/status-logs and GET /application/:id/status-logs
New /application-status-logs admin page that lists every application
status change with the affected applicant, the acting user and the
previous/new status.

- client-side filtering (per-column text + date range), sorting and
  pagination, reusing the periods DataTable building blocks
- useApplicationStatusLogs hook + entity type
- linked from the admin dashboard

@BarnaPuppi BarnaPuppi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Én a backendben nem láttam problémát, de pls valaki hozzáértő is nézze át azért

@TGyAkos TGyAkos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Other than the magic value, it LGTM

try {
await this.prisma.application.findUniqueOrThrow({ where: { id } });
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2025') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please wrap your magic values in local constants

@TGyAkos
TGyAkos self-requested a review September 10, 2026 20:39
drive by: extract prisma magic constants
- applyStatusChange now locks the row (SELECT ... FOR UPDATE) and re-reads
  its status inside the same transaction right before updating, instead of
  trusting a status snapshot the caller read earlier — fixes the audit log
  potentially recording the wrong previousStatus under concurrent updates.
- getActiveApplications now accepts the transaction client so
  setActiveApplicationsStatus reads through the same tx it writes with.
- Removed redundant manual updatedAt: new Date() now that Prisma's
  @updatedat already sets it on every update/updateMany.
- Narrowed applyStatusChange's client param to PrismaTransactionClient
  (the PrismaService arm was never used).
- Made SortableFilterableHeader/DateSortableFilterableHeader generic so
  application-status-logs/columns.tsx no longer needs an unsafe
  as unknown as Column<ApplicationEntity> cast.
@mozsarmate
mozsarmate merged commit fddbda2 into main Sep 14, 2026
2 of 4 checks passed
@mozsarmate
mozsarmate deleted the feat/audit-log branch September 14, 2026 15:34

This branch was successfully deployed

1 active deployment
Preview — bca3b9c1 Deployed Sep 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants