mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 08:54:10 +01:00
* Add duration to autotag finish message * No sorting scene/image/gallery where not specified * Use an LRU cache for sqlite regexp function * Compile path separator regex once * Cache objects with single letter first names * Move finished auto-tag log * Add more verbose logging * Add new changelog
32 lines
511 B
Go
32 lines
511 B
Go
package database
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func durationToTinyIntFn(str string) (int64, error) {
|
|
splits := strings.Split(str, ":")
|
|
|
|
if len(splits) > 3 {
|
|
return 0, nil
|
|
}
|
|
|
|
seconds := 0
|
|
factor := 1
|
|
for len(splits) > 0 {
|
|
// pop the last split
|
|
var thisSplit string
|
|
thisSplit, splits = splits[len(splits)-1], splits[:len(splits)-1]
|
|
|
|
thisInt, err := strconv.Atoi(thisSplit)
|
|
if err != nil {
|
|
return 0, nil
|
|
}
|
|
|
|
seconds += factor * thisInt
|
|
factor *= 60
|
|
}
|
|
|
|
return int64(seconds), nil
|
|
}
|