Sort duplicate scene groups by total filesize descending (#6133)

This commit is contained in:
underprovisioned 2025-10-15 01:52:40 -04:00 committed by GitHub
parent 05e2fb26be
commit eb816d2e4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,7 +79,24 @@ export const SceneDuplicateChecker: React.FC = () => {
}, },
}); });
const scenes = data?.findDuplicateScenes ?? []; const getGroupTotalSize = (group: GQL.SlimSceneDataFragment[]) => {
// Sum all file sizes across all scenes in the group
return group.reduce((groupTotal, scene) => {
const sceneTotal = scene.files.reduce(
(fileTotal, file) => fileTotal + file.size,
0
);
return groupTotal + sceneTotal;
}, 0);
};
const scenes = useMemo(() => {
const groups = data?.findDuplicateScenes ?? [];
// Sort by total file size descending (largest groups first)
return [...groups].sort((a, b) => {
return getGroupTotalSize(b) - getGroupTotalSize(a);
});
}, [data?.findDuplicateScenes]);
const { data: missingPhash } = GQL.useFindScenesQuery({ const { data: missingPhash } = GQL.useFindScenesQuery({
variables: { variables: {