mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Restructure data layer (#2532)
* Add new txn manager interface * Add txn management to sqlite * Rename get to getByID * Add contexts to repository methods * Update query builders * Add context to reader writer interfaces * Use repository in resolver * Tighten interfaces * Tighten interfaces in dlna * Tighten interfaces in match package * Tighten interfaces in scraper package * Tighten interfaces in scan code * Tighten interfaces on autotag package * Remove ReaderWriter usage * Merge database package into sqlite
This commit is contained in:
32
pkg/sqlite/functions.go
Normal file
32
pkg/sqlite/functions.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package sqlite
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user