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

fix: remove duplicateIds on unique assets #13752

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
16 changes: 14 additions & 2 deletions server/src/services/duplicate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ import { usePagination } from 'src/utils/pagination';
export class DuplicateService extends BaseService {
async getDuplicates(auth: AuthDto): Promise<DuplicateResponseDto[]> {
const res = await this.assetRepository.getDuplicates({ userIds: [auth.user.id] });

return mapDuplicateResponse(res.map((a) => mapAsset(a, { auth, withStack: true })));
const uniqueAssetIds: string[] = [];
Copy link
Member

@bo0tzz bo0tzz Oct 27, 2024

Choose a reason for hiding this comment

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

Naming nitpick: These aren't necessarily unique, right (more accurately, all assetIds are unique)? Not sure what a better name would be though.

Copy link
Contributor

Choose a reason for hiding this comment

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

singletonDuplicateIds?

const duplicates = mapDuplicateResponse(res.map((a) => mapAsset(a, { auth, withStack: true }))).filter(
(duplicate) => {
if (duplicate.assets.length === 1) {
uniqueAssetIds.push(duplicate.assets[0].id);
return false;
}
return true;
},
);
if (uniqueAssetIds.length > 0) {
void this.assetRepository.updateAll(uniqueAssetIds, { duplicateId: null });
Pranay-Pandey marked this conversation as resolved.
Show resolved Hide resolved
}
return duplicates;
}

async handleQueueSearchDuplicates({ force }: IBaseJob): Promise<JobStatus> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
import { getAssetDuplicates } from '@immich/sdk';
import { getAssetDuplicates, updateAssets, type DuplicateResponseDto } from '@immich/sdk';

Check warning on line 4 in web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts

View workflow job for this annotation

GitHub Actions / Test & Lint Web

'updateAssets' is defined but never used. Allowed unused vars must match /^_$/u

Check warning on line 4 in web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts

View workflow job for this annotation

GitHub Actions / Test & Lint Web

'DuplicateResponseDto' is defined but never used. Allowed unused vars must match /^_$/u
import type { PageLoad } from './$types';

export const load = (async ({ params }) => {
Expand Down
Loading