Skip to content

feat(server): asset entity audit - #3824

Merged
jrasm91 merged 16 commits into
mainfrom
dev/audit-endpoint
Aug 24, 2023
Merged

jrasm91 merged 16 commits into
mainfrom
dev/audit-endpoint

Conversation

@fyfrey

@fyfrey fyfrey commented Aug 21, 2023 •

Copy link
Copy Markdown
Collaborator

continues from #3592 (rebased)

Features:

  • Deletes automatically populated by TypeORM hooks (thanks @alextran1502 )
  • Get deletes after a certain date (with check whether a full sync is required)
  • Asset API endpoint returns changed assets via updatedAfter query param
  • New nightly job to clean audit log table entries older than 100 days

Tested Scenarios:

  • Favorite an asset in the web, view updated date is updated
  • Unfavorite an asset in the web, view updated date is updated
  • Archive an asset in the web, view updated date is updated
  • Unarchive an asset in the web, view updated date is updated
  • Delete an asset in the web, view audit log is created
  • Delete an album in the web, view audit log is created
  • Query deletes with old date (> 100 years) and see needsFullSync is true
  • Query assets by updatedAt and view recently updated assets are returned
  • Run refresh metadata on a single asset and verify updated date is changed
  • Upload a new asset and verify asset is returned in recent updates query

@vercel

vercel Bot commented Aug 21, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Aug 24, 2023 6:27pm

@fyfrey
fyfrey force-pushed the dev/audit-endpoint branch from 755bc00 to fc338c2 Compare August 21, 2023 22:20
@fyfrey fyfrey changed the title feat(server): audit endpoint feat(server): changed assets endpoint Aug 22, 2023
@fyfrey
fyfrey marked this pull request as ready for review August 22, 2023 17:14
@fyfrey
fyfrey requested a review from jrasm91 August 22, 2023 17:15
@jrasm91

jrasm91 commented Aug 22, 2023

Copy link
Copy Markdown
Member

What is the difference between the two new endpoints and do we need them both? Can we keep all the audit stuff in one controller/service?

Comment thread server/src/domain/audit/audit.service.ts Outdated
Comment thread server/src/domain/audit/audit.service.ts Outdated
Comment thread server/src/domain/audit/audit.service.ts Outdated
Comment thread server/src/domain/audit/audit.service.ts Outdated
Comment thread server/src/domain/audit/audit.repository.ts Outdated
Comment thread server/src/domain/asset/asset.service.ts Outdated
Comment thread server/src/domain/asset/response-dto/changed-assets-response.dto.ts Outdated
Comment thread server/src/domain/asset/asset.service.ts Outdated
Comment thread server/src/infra/entities/audit.entity.ts Outdated
@fyfrey

fyfrey commented Aug 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

Many thanks for the review @jrasm91
I'll fix the style remarks etc.

Regarding the new endpoints: I guess we actually don't need the audit controller at all (and only keep getChanges in the asset controller). Or would you prefer to move getChanges to the audit controller (as it's only method). The audit service only needs the cleanup method for the Cron job (unless I move getChanges to the audit controller)

@fyfrey
fyfrey force-pushed the dev/audit-endpoint branch from 443a357 to e78b273 Compare August 24, 2023 06:49
@jrasm91
jrasm91 force-pushed the dev/audit-endpoint branch from b952a0d to d330bcf Compare August 24, 2023 18:27
@jrasm91 jrasm91 changed the title feat(server): changed assets endpoint feat(server): asset entity audit Aug 24, 2023
@jrasm91
jrasm91 merged commit cf9e04c into main Aug 24, 2023
@jrasm91
jrasm91 deleted the dev/audit-endpoint branch August 24, 2023 19:28
martabal pushed a commit that referenced this pull request Sep 11, 2023
* feat(server): audit log

* feedback

* Insert to database

* migration

* test

* controller/repository/service

* test

* module

* feat(server): implement audit endpoint

* directly return changed assets

* add daily cleanup of audit table

* fix tests

* review feedback

* ci

* refactor(server): audit implementation

* chore: open api

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com>
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
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.

4 participants