Skip to content
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

refactor(server): extract add/remove assets logic to utility function #8329

Merged
merged 1 commit into from Mar 29, 2024

Conversation

danieldietzler
Copy link
Member

No description provided.

Copy link

cloudflare-pages bot commented Mar 28, 2024

Deploying immich with  Cloudflare Pages  Cloudflare Pages

Latest commit: e0d0dc3
Status: ✅  Deploy successful!
Preview URL: https://5c6d2d77.immich.pages.dev
Branch Preview URL: https://refactor-bulk-asset-operatio.immich.pages.dev

View logs

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Looks really nice! Thanks!

@danieldietzler danieldietzler force-pushed the refactor/bulk-asset-operations branch 3 times, most recently from ed11f3f to 5378181 Compare March 28, 2024 20:31
server/src/services/album.service.ts Show resolved Hide resolved

const removedIds = results.filter(({ success }) => success).map(({ id }) => id);
if (removedIds.length > 0) {
await this.albumRepository.removeAssets(id, removedIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's possible here since we need to answer two questions: (1) Did any ids actually get removed? (2) Was the thumbnail asset id part of those removed ids?


const newAssetIds = results.filter(({ success }) => success).map(({ id }) => id);
if (newAssetIds.length > 0) {
await repository.addAssetIds(dto.id, dto.assetIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a bug? Surely it should be the new asset IDs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooh, great catch

Copy link
Member Author

Choose a reason for hiding this comment

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

Dang you're good

Copy link
Contributor

@mertalev mertalev left a comment

Choose a reason for hiding this comment

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

LGTM!

server/src/repositories/album.repository.ts Show resolved Hide resolved
server/src/utils/asset.util.ts Show resolved Hide resolved
server/src/utils/asset.util.ts Show resolved Hide resolved
fix tests

chore: generate sql

foo
@jrasm91 jrasm91 merged commit 6f677b4 into main Mar 29, 2024
24 checks passed
@jrasm91 jrasm91 deleted the refactor/bulk-asset-operations branch March 29, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants