fix(duplicates): use server-side path filter instead of client-side filtering
Move basePath filtering from client-side startsWith check to server-side query filter (path:basePath*) for consistency with map implementation and improved efficiency. Reduces amount of data fetched when user has a basePath configured. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,23 +25,18 @@ export interface DuplicateGroup {
|
||||
}
|
||||
|
||||
export async function listDuplicateGroups(basePath?: string): Promise<DuplicateGroup[]> {
|
||||
// Build query: stack:true + optional path filter
|
||||
const pathFilter = basePath ? ` path:${basePath}*` : '';
|
||||
const q = `stack:true${pathFilter}`;
|
||||
|
||||
const photos = await listPhotos({
|
||||
q: 'stack:true',
|
||||
q,
|
||||
count: 200,
|
||||
merged: true,
|
||||
order: 'newest'
|
||||
});
|
||||
return photos
|
||||
.filter((p) => {
|
||||
// Filter out photos not in the current user's base path
|
||||
if (basePath) {
|
||||
const photoPath = p.Path ?? '';
|
||||
if (!photoPath.startsWith(basePath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (p.Files?.length ?? 0) > 1;
|
||||
})
|
||||
.filter((p) => (p.Files?.length ?? 0) > 1)
|
||||
.map((p) => {
|
||||
const files = p.Files ?? [];
|
||||
const primary = files.find((f) => f.Primary) ?? files[0];
|
||||
|
||||
Reference in New Issue
Block a user