mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 17:02:38 +01:00
Sort duplicate scenes by path (#3157)
This commit is contained in:
parent
ebf3a4ba8e
commit
8ab095f675
1 changed files with 22 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -1706,5 +1707,26 @@ func (qb *SceneStore) FindDuplicates(ctx context.Context, distance int) ([][]*mo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortByPath(duplicates)
|
||||||
|
|
||||||
return duplicates, nil
|
return duplicates, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sortByPath(scenes [][]*models.Scene) {
|
||||||
|
lessFunc := func(i int, j int) bool {
|
||||||
|
firstPathI := getFirstPath(scenes[i])
|
||||||
|
firstPathJ := getFirstPath(scenes[j])
|
||||||
|
return firstPathI < firstPathJ
|
||||||
|
}
|
||||||
|
sort.SliceStable(scenes, lessFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFirstPath(scenes []*models.Scene) string {
|
||||||
|
var firstPath string
|
||||||
|
for i, scene := range scenes {
|
||||||
|
if i == 0 || scene.Path < firstPath {
|
||||||
|
firstPath = scene.Path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return firstPath
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue